0

enter image description here

enter image description here

When I tried to plot the the excel file, The graph did not show the X axis. Does anyone can help?

Thanks in advance

x=data['hour_formatted']

y=data['01_aug_18']

plt.plot (x, y)

plt.show()
hong developer
  • 13,291
  • 4
  • 38
  • 68
Alisha
  • 61
  • 1
  • 6
  • What do you mean, did not show the X axis? – Itamar Mushkin Aug 20 '19 at 05:06
  • What is your error message? Does it not "find" the defined column/row X? Or is the result in plt.show() empty? If you get an error for the X definition (hour_formatted), then you probably misspelled. If plt.show() is empty, then you don't have any data in that field. – Xaphas Aug 20 '19 at 05:15
  • Thank you for your response. I've attached the picture – Alisha Aug 20 '19 at 05:21
  • @ItamarMushkin I have attached the photo of my problem – Alisha Aug 20 '19 at 06:41

1 Answers1

0

There's probably a better solution, but try this:

data.set_index('hour_formatted')['01_aug_18'].plot()

It worked on my end and shows values properly, axis labels and everything.

Itamar Mushkin
  • 2,803
  • 2
  • 16
  • 32
  • Thank you so much for your help. The code that you provide is worked. @Itamar Mushkin – Alisha Aug 21 '19 at 02:39
  • but how should I put name for X and Y axis? @ItamarMushkin – Alisha Aug 21 '19 at 02:46
  • @Alisha The X axis should have the name of the index column (`'hour_formatted'` in this case). If you want to change them, call `plt.xlabel('new x label')` and `plt.ylabel('new y label')` – Itamar Mushkin Aug 21 '19 at 07:38
  • If the answer answered your question, please mark is as accepted (with the little green V) so it's visible that it's closed – Itamar Mushkin Aug 21 '19 at 07:39
  • Also, see: https://stackoverflow.com/questions/21487329/add-x-and-y-labels-to-a-pandas-plot – Itamar Mushkin Aug 21 '19 at 07:39
  • I dont know how to marked your answer, can you please tell me how? can you also give help for another question https://stackoverflow.com/questions/57584172/how-to-plot-bar-chart-for-data-with-1440-rows-%c3%97-297-columns – Alisha Aug 21 '19 at 07:54
  • There's a little grey V to the left of the question. See here: https://stackoverflow.com/tour – Itamar Mushkin Aug 21 '19 at 07:55
  • Can you please help me in this case as well? Thanks in advance https://stackoverflow.com/questions/57584172/how-to-plot-bar-chart-for-data-with-1440-rows-%c3%97-297-columns – Alisha Aug 21 '19 at 08:00