16.坐标轴的刻度

 1 import matplotlib.pyplot as plt
 2 import matplotlib as mp1
 3 import numpy as np
 4 import datetime
 5 fig = plt.figure()
 6 star = datetime.datetime(2015,1,1)
 7 stop = datetime.datetime(2016,1,1)
 8 delta = datetime.timedelta(days=1)
 9 
10 dates = mp1.dates.drange(star,stop,delta)
11 
12 y = np.random.rand(len(dates))
13 
14 ax = plt.gca()
15 
16 ax.plot_date(dates,y,linestyle='-',marker='')
17 date_format = mp1.DateFormatter('%Y-%m-%d')
18 ax.xaxis.set_major_formatter(date_format)
19 fig.autofmt_xdate()
20 
21 plt.show()

 

  

1 import matplotlib.pyplot as plt
2 import numpy as np
3 x = np.arange(1,11,1)
4 plt.plot(x,x)
5 ax = plt.gca()
6 ax.locator_params('y',nbins=20,
7                   # 'x',nbins=20,
8                   )
9 plt.show()

16.坐标轴的刻度_第1张图片

你可能感兴趣的:(16.坐标轴的刻度)