vasili111
vasili111

Reputation: 6940

How to adjust horizontal lines of error bars?

Here is a code:

import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Bar(
    name='Group 1',
    x=['Var 1', 'Var 2', 'Var 3'], y=[3, 6, 4],
    error_y=dict(type='data', array=[1, 0.5, 1.5]),
    width=0.15
))
fig.add_trace(go.Bar(
    name='Group 2',
    x=['Var 1', 'Var 2', 'Var 3'], y=[4, 7, 3],
    error_y=dict(type='data', array=[0.5, 1, 2]),
    width=0.15
))
fig.update_layout(barmode='group')
fig.show()

It works well and produces:


enter image description here



Question: How to change the length of the horizontal lines at the end of of error bars? I mean this ones:


enter image description here

Upvotes: 3

Views: 338

Answers (1)

Cedric Zoppolo
Cedric Zoppolo

Reputation: 4743

You just need to set the width parameter like this:

error_y=dict(type='data', array=[0.5, 1, 2], width=20)

Output example

After modifying that line for Group 2 in your code you can get for example:

enter image description here

Parameters reference

You can see the reference for parameters under https://plotly.com/python/reference/

Upvotes: 2

Related Questions