I'm creating an HTML report with a lot of plots and corresponding tables. It's quite big, so it would be great if the user could copy/paste the plot title into Find In Page to quickly find the associated table(s).
This answer made me realise that's not possible and that printing the title to the screen would help.
However, I want to display the charts in 2 columns.
Is it possible to print the title, display a plot, print a title to the right, display a plot to the right, begin next column, and so on, without using plt.subplots()?
If not in matplotlib, are there any plotting packages that could do this?
I was making a course on Datacamp about Interactive Graphs with Bokeh. So I tried to do the same in Jupyter Notebook. I put the link of my code here:
https://github.com/Kkkihon/Interactive-Data-Visualizations/blob/d014755354aaaa2a1e382373c519a18c3e1c7d42/Graphs
My problems are:
On the THIRD GRAPH my legend is just "region" but i want to change it to show all the countries of my data list in the column "region"
On the FOURTH GRAPH when I move the Slider the title of the graph should change and also the dots on the graph but it doesn't happen.
On the SIXTH GRAPH my graph should change the values on the axis but my values remains on life vs fertility.
I'm clearly new to using python language and I don't want someone to do everything for me either. I want to understand why I have these problems and correct myself.
I am trying to plot chart in my data science project. And I want to plot chart in this way
which is produced by Matplotlib library. And now I want to plot in the same way. But it gives me this way in bokeh.
My data for this in the form of python list and it is as below:
ages = [45.0,50.0,55.0,40.0,60.0,35.0,65.0,30.0,70.0,25.0,75.0,20.0,80.0,85.0,15.0,90.0,10.0,0.0]
ageCounter = [4466,4270,3824,3576,3240,2850,2527,2358,1968,1544,981,655,419,149,132,80,17,2]
Is there any thing I am missing.
Thanks in advance.
You need to sort the arrays together by age. Bokeh plots the points in the order you pass them in. The data above is out of order which explains the "zigzag".
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'm preparing a set of reports using open source ReportLab. The reports contain a number of charts. Everything works well so far.
I've been asked to take a (working) bar chart that shows two series of data and overlay a fitted curve for each series.
I can see how I could overlay a segmented line on the bar graph by creating both a line chart and bar chart in the same ReportLab drawing. I can't find any reference for fitted curves in ReportLab, however.
Does anyone have any insight into plotting a fitted curve to a series of data in ReportLab or, failing that, a suggestion about how to accomplish this task (I'm thinking that chart would need to be produced in matplotlib instead)?
I would recommend using MatPlotLib. This is exactly the sort of thing it's designed to handle and it will be much easier than trying to piece together something in ReportLab alone, especially since you'll have to do all the calculation of the line on your own and figure out the details of how to draw it in just the right place. MatPlotLib integrates easily with ReportLab; I've used the combination several times with great results.