简体   繁体   中英

python pandas: how to switch x-axis with y-axis for a line graph

I have a problem with creating a line graph. I need to switch the x-axis with y-axis.

My idea is to visualize the Branch (F1, F2, F3, F4) on the y-axis and the weeks from 1-100 on the x-axis

If you have any idea how to do this please comment :) Thanks!

My data looks like that: data

My code:

data.set_index('Branch').plot()
plt.show()

after I plot my data

Try transposing the DataFrame prior to plotting:

data.set_index('Branch').T.plot()
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM