My values are:
x = [32, 13, 24, 7, 9]
y = [β0β, β1β, β2 to 5β, β6 to 10β, β>10β]
It looks like plotly things that my y values are numbers and plots the 2 first values of my list (0 and 1).
My chart then shows as y ticks: -0.5, 0, 0.5, 1, 1.5 instead of β0β, β1β, β2 to 5β, β6 to 10β, β>10β.
How do I do to tell plotly that my y values are strings and not numbers ?
Thanks for your help.
C
@christianv You can do this by using the layout.yaxis.type
attribute. Setting it to 'categorical'
should do the trick.
Thank you very much Michael for your help. How should I write this into the following code ?
data = [go.Bar(x=x, y=y, text=x, textposition = βautoβ, orientation=βhβ, marker=dict(color=colors))]
layout = go.Layout(margin=go.layout.Margin(l=530, r=50, b=90, t=90, pad=25), autosize=False, width=2000, height=1000, font=dict(size=45))
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename=βhorizontal-barβ)
pio.write_image(fig, Q2.jpg")
In advance, thank you for your help.
Best,
C
found it:
layout = go.Layout(margin=go.layout.Margin(l=200, r=50, b=90, t=90, pad=25), autosize=False, width=2000, height=800, font=dict(size=45), yaxis=dict(type=βcategoryβ))
thanks,
C