Horizontal Bar Charts
I can’t turn the bar chart and https:// plot.ly/python/table/ into horizontal – I tried to use
orientation = 'h', but both failed. Here is a piece of the code:
# Make traces for graph
trace1 = go.Scatter(x=teams, y=GFPG, type='bar', orientation = 'h',
name='Goals For<br>Per Game',
trace2 = go.Scatter(x=teams, y=GAPG, type='bar', orientation = 'h',
name='Goals Against<br>Per Game',
# Add trace data to figure
data = [trace1, trace2]
fig = go.Figure(data=data) #, layout=layout)
Full code is at, https:// gist.github.com/suntong/6e3f4cbd8056c699c0d2.
That should be
go.Scatter (the example at https://plot.ly/python/table/ has been updated to reflect this)
orientation = 'h' should work
Thanks chelsea, yeah, it’s working.
However, there are still two things I still can’t fix myself. Please take a look at the updated https://gist.github.com/suntong/6e3f4cbd8056c699c0d2
"In " is working, but the yaxis is upside-down, I tried to reverse it myself, like below,
layout = go.Layout(
But it is not working.
Further, there is no much room to display full y-lables. All my labels are arranged such that the words from the beginning of the label are much more important than the ending. So it is also possible to show the beginning of the label instead of the end of it, if there isn’t enough room to display all.
Please help. Thanks
Taking a look at your example it looks like the axis you want to reverse is actually yaxis2 so you can run
For the other issue I would suggest editing the margins. There's some information on that on our reference page here: https://plot.ly/python/reference/#layout-margin