0

So i want to plot a small and close values to see the difference between them. I'm using matplotlib.pyplot.plot but the y limits are too big compare to my data which is:

2.663689859547342e-08
7.999154916053879e-09
7.99915525716199e-09
7.999155333718048e-09

code:

plt.figure(figsize=(10,12))
plt.grid()
plt.yscale('log')
plt.scatter([1,2,3,4],norm_vector)

enter image description here

Can i scale the y limits so that my values difference is more visible?

no1special
  • 49
  • 5
  • 2
    Yes with [matplotlib.pyplot.ylim](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.ylim.html#matplotlib-pyplot-ylim) – Clément Nov 28 '19 at 09:59

2 Answers2

1

You can get or set the y limits of your y axis -

bottom, top = ylim()  # return the current ylim

ylim((bottom, top))   # set the ylim to bottom, top

ylim(bottom, top)     # set the ylim to bottom, top

or you could just specify the bottom or up -

ylim(top=3)  # adjust the top leaving bottom unchanged

ylim(bottom=1)  # adjust the bottom leaving top unchanged
Clément
  • 1,128
  • 7
  • 21
E. Gertz
  • 241
  • 4
  • 13
0

Problem solved. I just used plt.plot to produce scatter and y limits changed.

plt.plot([1,2,3,4],norm_vector,'bo')
no1special
  • 49
  • 5