1

I'm writing a matplotlib program to plot a simple graph of sunspot numbers against the year that they were recorded. I want to set my y axis to begin at 0 and my x axis to begin at 1725. I have tried using set_xlim and set_ylim but I get the error message AttributeError: module 'matplotlib.pyplot' has no attribute 'set_ylim'

I am a matplotlib beginner. I previously tried using plt.xticks(np.arange()) to try and change the axes but this didn't do anything outside of just changing the frequency of ticks.

plt.set_xlim(xmin=1750) # set x axis minimum to 1750 (the time axis)
plt.xticks(np.arange(1750,2050,25)) # ticks begin at 1750, every 25 years
plt.set_ylim(ymin=0) # set y axis minimum to 0
plt.yticks(np.arange(0,max(numbers)+100,50)) # ticks begin at 0, every 50 sunspots

I want my axes to begin at 0 and 1750. Instead when I plot my graph I get a buffer around 1750 and 0 which looks sloppy and an error message for using set_xlim and set_ylim.

Masoud
  • 1,270
  • 7
  • 12
Oliver
  • 11
  • 1
  • 2

0 Answers0