Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Created September 21, 2024 06:20
Show Gist options
  • Save razhangwei/4fafdae383147c10af465f89f8864293 to your computer and use it in GitHub Desktop.
Save razhangwei/4fafdae383147c10af465f89f8864293 to your computer and use it in GitHub Desktop.
pyplot express example
# Create an interactive bar chart with two bars per date
fig = go.Figure()
fig.add_trace(go.Bar(
x=daily_formula_intake.index,
y=daily_formula_intake.values,
name='Formula'
))
fig.add_trace(go.Bar(
x=daily_expressed_intake.index,
y=daily_expressed_intake.values,
name='Expressed'
))
# Add linear regression line
fig.add_trace(go.Scatter(
x=daily_total_intake.index,
y=y_pred,
mode='lines',
name='Linear Regression'
))
fig.update_layout(
title='Daily Total Milk Intake (Formula + Expressed)',
xaxis_title='Date',
yaxis_title='Total Amount (ml)',
barmode='stack' # Stack the bars for formula and expressed
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment