I really like the way that a plotly express allows you to generate a histogram with a box plot.
My simple example is shown below.
I’d really like to be able to combine a simple html table displaying some data. I don’t want to use dash as I want to be able to share this as a html page with someone.
Is there a way to do this with plotly express?
If not, does anyone know how a similar histogram + box plot could be created with plotly go?
import pandas as pd
import numpy as np
import plotly.express as px
person_count = 1000
df1 = pd.DataFrame({
‘gender’ : [‘male’] * person_count,
‘height’ : np.random.normal(179, 20, person_count)
})
df2 = pd.DataFrame({
‘gender’ : [‘female’] * person_count,
‘height’ : np.random.normal(165, 20, person_count)
})
df = pd.concat([df1, df2], ignore_index=True)
fig = px.histogram(df, x=‘height’,
color=‘gender’,
nbins=50,
opacity=0.40,
marginal=‘box’,
labels={‘height’: ‘Height (cm)’},
title=‘Person Height’)
fig.write_html(‘height_histogram.html’, auto_open=True)