Altair offers lovely feature to facet charts using facet method. For example, following dataset visualizes nicely:
print(df[['Year', 'Profile', 'Saison', 'Pos']].to_csv())
,Year,Profile,Saison,Pos
0,2017,6.0,Sommer,VL
1,2017,6.0,Winter,VL
13,2017,6.0,Winter,HL
12,2017,6.0,Sommer,HL
18,2017,6.0,Sommer,HR
6,2017,6.0,Sommer,VR
7,2017,6.0,Winter,VR
19,2017,6.0,Winter,HR
14,2018,5.5,Winter,HL
8,2018,5.5,Winter,VR
15,2018,5.5,Sommer,HL
20,2018,4.3,Winter,HR
21,2018,5.0,Sommer,HR
3,2018,5.5,Sommer,VL
2,2018,6.2,Winter,VL
9,2018,4.5,Sommer,VR
17,2019,4.5,Sommer,HL
11,2019,4.2,Sommer,VR
22,2019,3.5,Winter,HR
10,2019,5.28,Winter,VR
5,2019,4.6,Sommer,VL
4,2019,4.9,Winter,VL
16,2019,4.0,Winter,HL
23,2019,4.5,Sommer,HR
with the following command:
alt.Chart(df).mark_bar().encode(x='Year:O', y='Profile:Q').facet(row='Saison:N', column='Pos:N')
But, as you can seem I have still a lot of place horizontally and would like to use it by rearranging Winter plot right next to the Summer plot:
I understand that I already used column grid to facet over attribute Pos, but visually for me Winter and Sommer plots are two separate plots (just like here), which I'd like to place side by side.
I tried to create two different charts in the same cell and using html emit them side by side, but in Jupyter environment there is a limitation on just one Altair/Vega plot per cell.
Is there any method I can use to arrange these charts horizontally?
In Altair, there is no good way to do this, because faceted charts cannot be nested according to the Vega-Lite schema. However, the Vega-Lite renderer actually does handle this in some cases, despite it technically being disallowed by the schema.
So you can hack it by doing something like this:
chart = alt.Chart(df).mark_bar().encode(
x='Year:O',
y='Profile:Q'
).facet('Saison:N')
spec = alt.FacetChart(
data=df,
spec=chart,
facet=alt.Facet('Pos:N')
).to_json(validate=False)
print(spec)
The resulting spec can be pasted by hand into http://vega.github.io/editor to reveal this (vega editor link):
You'll even notice that the vega editor flags parts of the spec as invalid. This is admittedly not the most satisfying answer, but it sort of works.
Hopefully in the future the Vega-Lite schema will add actual support for nested facets, so they can be used more directly from Altair.
I am using plotly in Python 2.7 to produce Gantt charts like -
But instead of filling the individual bars with color, I wish to fill them with different patterns so that it can be read even when printed in grey scale.
Is there a way to do that in Plotly? If not what other Python packages can do it?
Thanks!
I'm just starting to take a look at Bokeh for data visualization and am wondering the advantage/disadvantage to using Figure.vbar() vs Bar() if someone could clarify.
bar is from the high level Charts interface. It gives you quick, easy access to bar charts with limited control.
vbar is from the mid level Plotting interface and gives you more control over the layout of your bar chart. Alternatives to vbar would be rect and quad, both from the Plotting interface. They give a few distinctive options for bar shape, location, etc.
bar is much easier if you don't need to do anything fancy. If you decide you want more control over your plot (like HoverTool etc) you will have to instantiate a Figure and use one of it's methods.
bar docs Here
and
vbar docs Here
I use both, depending on my needs.
In Bokeh 0.12.2, I was able to make a stacked bar chart with various hover tooltips using plotting and VBars. I also enabled a legend for the plot. However, my vbars are colored and the colors for each vbar (each stack) are not appearing in the legend. Only the names for the stack in the legend are appearing. Is this not an implemented feature yet or a bug maybe? Or maybe I'm missing something?
what my chart looks like
This was due to a bug in the bokeh source code which is being fixed if not fixed already.
Bokeh:
Can anyone provide some guidance on creating the horizontal scroll bar similar to the one shown in the image below such? Does anything of the like exist? Is this feasible without fiddiling D3.js? Graph can be viewed at
https://fred.stlouisfed.org/series/GDP#
Use python-highcharts instead. The graph you showed is apparently using highcharts.