Error bars from .csv file

How can I display error bars from a .csv file, i.e. error_y should take the values as specified in β€œ10 Min Std Dev”? Thanks a lot for your help!


import plotly.graph_objects as go
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_speed_laurel_nebraska.csv')

fig = go.Figure([
    go.Scatter(
        name='Measurement',
        x=df['Time'],
        y=df['10 Min Sampled Avg'],
        mode='markers',
        marker=dict(color='red', size=5),
        
                    
        error_y=dict(
            type='data', # value of error bar given in data coordinates
            array=[1, 2, 3],
            visible=True, color='blue', width=5, thickness=0.1)
    )
 ])

fig.update_layout(template='simple_white',
    yaxis_title='Wind speed (m/s)',
    title='Continuous, variable value error bars',
    hovermode="x"
)
    
fig.show()

Hi @windrose,

Welcome to the community!

I am not sure what you intended to to with array=[1, 2, 3], the error_y data should be the same length as x and y, that’s why it is not working. Here is the way it can be done using plotly express:

hope it helps, Alex-

import plotly.express as px

fig = px.scatter(df, x='Time', y='10 Min Sampled Avg', error_y='10 Min Std Dev')

fig.update_traces(
    error_y=dict(color='blue', width=5, thickness=0.1),
    marker=dict(color='red', size=5)
)

fig.update_layout(template='simple_white',
    yaxis_title='Wind speed (m/s)',
    title='Continuous, variable value error bars',
    hovermode="x"
)
    
fig.show()

1 Like

Great, thanks a lot!

Steps are given below-
Click anywhere in the chart.

Click the Chart Elements button Chart Elements button next to the chart, and then check the Error Bars box. (Clear the box to remove error bars.)

To change the error amount shown, click the arrow next to Error Bars, and then pick an option.

Pick a predefined error bar option like Standard Error, Percentage or Standard Deviation.

Pick More Options to set your own error bar amounts, and then under Vertical Error Bar or Horizontal Error Bar, choose the options you want. This is also where you can change the direction, end style of the error bars, or create custom error bars.

Regards,
Rachel Gomez