I am working with a new Python web framework called justpy which lets you build both the backend and the frontend of a web app using Python only. The framework also integrates with the javascript Highcharts library. Here's how to build a web app that contains a Highcharts plot:
import justpy as jp
import pandas as pd
wm = pd.read_csv('https://elimintz.github.io/women_majors.csv').round(2)
# Create list of majors which start under 20% women students
wm_under_20 = list(wm.loc[0, wm.loc[0] < 20].index)
def women_majors():
wp = jp.WebPage()
wm.jp.plot(0, wm_under_20, kind='spline', a=wp, title='The gender gap is transitory - even for extreme cases',
subtitle='Percentage of Bachelors conferred to women form 1970 to 2011 in the US for extreme cases where the percentage was less than 20% in 1970',
classes='m-2 p-2 w-3/4')
return wp
jp.justpy(women_majors)
that will load the webapp on localhost:8000:
I am now trying to figure out how to display the Highcharts plot only, without having to build a web app.
If I modify the above code to this:
import justpy as jp
import pandas as pd
wm = pd.read_csv('https://elimintz.github.io/women_majors.csv').round(2)
# Create list of majors which start under 20% women students
wm_under_20 = list(wm.loc[0, wm.loc[0] < 20].index)
fig = wm.jp.plot(0, wm_under_20, kind='spline', title='The gender gap is transitory - even for extreme cases',
subtitle='Percentage of Bachelors conferred to women form 1970 to 2011 in the US for extreme cases where the percentage was less than 20% in 1970',
classes='m-2 p-2 w-3/4')
print(fig)
That will return the following output:
HighCharts(id: 1, vue_type: chart, chart options: {'series': [{'data': [4.23,...
How can I make an image file out of that HighCharts object (or show the plot in a Jupyter notebook) without having to build a web app?
from Making a Highcharts plot with Python
No comments:
Post a Comment