Iām trying to make a plot that starts at 1, but that still shows the gridline at 1.
However, when I do this, the first and last lines (at 1 and 5) get cut off.
Example:
animals=['a','b','c','d','e','f','g','h']
data=[1.2, 1, 2.4, 3.7, 2.1, 1.6, 4.1, 3]
negdata = [5-x for x in data]
fig = go.Figure([
go.Bar(
x=data,
y=animals,
orientation='h',
marker=dict(color='#1d66a6'),
hoverlabel=dict(font=dict(size=10, color='white')),
hovertemplate=
'<b>Mean:</b><br>' + # heading for the hovertext
'%{x:.1f}'
),
go.Bar(
x=negdata,
y=animals,
orientation='h',
marker=dict(color='rgba(0, 0, 0, 0.2)'),
hoverinfo='none'
),
])
fig.update_xaxes(range=[1,5], tickvals=[1, 3, 5])
fig.layout.update(
yaxis=dict(showticklabels=False,),
xaxis=dict(showticklabels=False),
bargap=.4,
showlegend=False,
margin=go.layout.Margin(l=10, r=10, t=90, b=50, pad=1),
barmode='stack'
)
pyo.iplot(fig)