Skip to content

Chart with Error Bars #17

@s2t2

Description

@s2t2

Add example using error bars, for example to display high and low and average temperatures. Can also be used for custom confidence intervals.

import pandas as pd
import plotly.express as px
import numpy as np

chart_df = daily_weather.copy()
chart_df.reset_index(inplace=True)

# Calculate differences for error bars
chart_df['err_high'] = chart_df['high'] - chart_df['avg']
chart_df['err_low'] = chart_df['avg'] - chart_df['low']

# Create scatter plot with asymmetric error bars
fig = px.scatter(chart_df, x='date', y='avg',
                 error_y="err_high",
                 error_y_minus="err_low",
                 title='Daily Temperature Average with Low-High Range')

fig.update_layout(
    xaxis_title='Date',
    yaxis_title='Temperature'
)

fig.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions