✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Plot different error bar values for max and min at each point

I would like to add error bars to my graph just to show the range of values observed (difference between the max and min observed values from the mean at each point in time). I can plot error bars based on data, but how do I plot one data set for max and one dataset for min?

xaxis1 = df_sw_sort.date.dt.date
trace0 = go.Scatter(x=xaxis1, y=df_sw_sort._mean18, mode='markers',
               error_y =dict(
                    type='data',
                    array = df_sw_sort.diff_max18,
                    visible=True))  #error bars take on max value - want separate max and min
trace1 = go.Scatter(x=xaxis1, y=df_sw_sort._max18, mode='markers')
trace2 = go.Scatter(x=xaxis1, y=df_sw_sort._min18, mode='markers' )
xaxis2 = df_wb.date.dt.date
trace3=go.Scatter(x=xaxis2, y = delLf18_constant, mode = 'markers+lines')

data=[trace0,trace1,trace2,trace3]

plotly.offline.iplot(data)

Help?? Very little documentation beyond simply adding simple error bars found online. Nor can I find doc of the parameters for ‘error_y’ that I can adjust.

Hi @spencerchad,

If I understand what you’re wanting to do correctly, I think you can use an approach similar to the Asymmetric Error Bars example (https://plot.ly/python/error-bars/#asymmetric-error-bars).

Basically, you need to set error_y.array to the difference between the max value and the mean. And set error_y.arrayminus to the difference between the mean and the min value.

Hope that helps!
-Jon

Nailed it. Exactly what I was looking for. Thanks!

1 Like