Plot using plotly
In [1]:
Copied!
"""
Plotly example
===================================
This is an example using plotly.
"""
"""
Plotly example
===================================
This is an example using plotly.
"""
Out[1]:
'\nPlotly example\n===================================\n\nThis is an example using plotly.\n'
In [2]:
Copied!
import plotly.express as px
import numpy as np
# mkdocs_gallery_thumbnail_path = '_static/newplot.png'
# The comment above is to set the thumbnail picture from a previously saved figure.
# This is required for plotly figures.
df = px.data.gapminder().query("year == 2007")
# Create a sunburst chart using Plotly
fig = px.sunburst(df, path=['continent', 'country'], values='pop',
color='lifeExp', hover_data=['iso_alpha'],
color_continuous_scale='RdBu',
color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
#fig.update_layout(title_text='Life expectancy of countries and continents')
fig.show(renderer="notebook")
import plotly.express as px
import numpy as np
# mkdocs_gallery_thumbnail_path = '_static/newplot.png'
# The comment above is to set the thumbnail picture from a previously saved figure.
# This is required for plotly figures.
df = px.data.gapminder().query("year == 2007")
# Create a sunburst chart using Plotly
fig = px.sunburst(df, path=['continent', 'country'], values='pop',
color='lifeExp', hover_data=['iso_alpha'],
color_continuous_scale='RdBu',
color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
#fig.update_layout(title_text='Life expectancy of countries and continents')
fig.show(renderer="notebook")