Adding bar that represents a variable in a dataset to a visualization
See original GitHub issueHi Jake,
I followed guide: https://altair-viz.github.io/gallery/us_population_over_time.html and was able to successfully create histogram along with slider. However, I would like to add another bar next to my current bar,which is my s2 column in dataset.So far, I tried inserting s2 in my below code. It didn’t work and returned empty plot:
y=alt.Y('sum(s1,s2):Q', scale=alt.Scale(domain=(0,120000000)))
,
I was wondering if something like that can be achievable ? Also, I was wondering if I can display two years (i.e 1920,1925) on single selection ? My code so far look like following.
Code:
from altair.expr import datum, if_
pink_blue = alt.Scale(domain=('PA', 'DC', 'TX'),
range=["steelblue", "salmon","Orange")
slider = alt.binding_range(min=1920, max=1930, step=1)
select_year = alt.selection_single(name="Year", fields=['Year'], bind=slider)
alt.Chart(df3).mark_bar().encode(
x=alt.X('Year:N', axis=alt.Axis(title=None)),
y=alt.Y('sum(s1):Q', scale=alt.Scale(domain=(0,120000000))),
color=alt.Color('Area:N', scale=pink_blue),
column='Area:O'
).properties(
width=450
).add_selection(select_year).transform_filter(select_year).properties(width=100)
Altair Rocks!!! 😃
Thanks in advance,
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
A Complete Guide to Bar Charts | Tutorial by Chartio
Bar charts are a fundamental visualization for comparing values between groups of data. ... The primary variable of a bar chart is its...
Read more >How to Make a Bar Graph With 3 Variables in Excel & Google ...
Data in a Bar graph with 3 variables is displayed using vertical or horizontal bars. The length or height of each bar is...
Read more >Quantitative comparisons and statistical visualizations
A stacked bar chart contains bars, where the height of each bar represents values. In addition, stacked on top of the first variable...
Read more >Visualizing a Categorical Variable
The bar chart is often used to show the frequencies of a categorical variable. By default, geom_bar uses stat = "count" and maps...
Read more >Bar Plots in Python | Beginner's Guide to Data Visualization ...
The length and heights of the bar chart represent the data distributed in the dataset. In a bar chart, we have one axis...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jakevdp That will be awesome 😃
It is possible to use altair in Kaggle, but you need to enable the notebook renderer:
With this you get even the interactions when you are working on a kernel. But the charts will not work when other people see the static version of it. For this, the strategy people are using is to do the following (source):
The you need to name your chart and pass it as an argument to the render function: