Home > Back-end >  python pandas: how to switch x-axis with y-axis for a line graph
python pandas: how to switch x-axis with y-axis for a line graph

Time:10-27

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

CodePudding user response:

Try transposing the DataFrame prior to plotting:

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