0

I want to plot a bar plot with this code:

graph_data = pd.read_csv('data.csv', usecols = ['X', 'Y'])

ax = graph_data.plot.bar(x='X', y='Y', figsize=(15, 5))
plt.title("X [-]")
plt.ylim([0,1120394]) #Max value from the dataset
plt.show()
  • I read the data from .csv file
  • Then I specify the ylim to [0,1120394] (which is the highest value in the dataset).
  • And plot the bar plot

The output plot:

enter image description here

  • As you can see the bars S29, S30, S33, S34 and S37 are cut.
  • I want to plot a bar plot that will show the full length of each column.
  • Also I would love if Y axis could show me the actual values? Why is it showing 1e6?

Edit

If I use the answer (and other answer referring to this) pointed out by the comments I end up with this code:

plt.ticklabel_format(style='plain') #To set off scientific notation
...
or
...
plt.ticklabel_format(useOffset=False)

Both lines get me those errors:

AttributeError: This method only works with the ScalarFormatter
Jakub Szlaur
  • 1,852
  • 10
  • 39
  • 2
    To show "actual values": [prevent scientific notation](https://stackoverflow.com/questions/28371674/prevent-scientific-notation-in-matplotlib-pyplot). About the bar's possible cut off: maybe they just touch the top. Default the ylims woud be set to `max(y)*1.05` – JohanC Apr 01 '21 at 22:04
  • @JohanC Hi and thank you for your comment! Unfortunately I tried those answers and they didn't work - I edited my question. – Jakub Szlaur Apr 01 '21 at 22:18
  • How would I do that please? If you want you can post your answer to this question. – Jakub Szlaur Apr 01 '21 at 22:21
  • 1
    `ax.ticklabel_format(axis='y', style='plain')` – JohanC Apr 01 '21 at 22:25
  • Thank you very much! As I said you can post your answer and I can accept it :) – Jakub Szlaur Apr 01 '21 at 22:26

0 Answers0