Recently busy writing papers, not updated for a long time, a little time today to share with you a script about their use matplotlib module trigonometric painting image, photograph image generated is a function of
talk is cheap,now,show the code
1 # -*- coding:utf-8 -*- 2 from matplotlib import pyplot as plt 3 import numpy as np 4 # 创建16:9矩形框,像素300dpi 5 plt.figure(figsize = (16,9), dpi = 300) 6 plt.subplot(111) 7 8 x = np.linspace(-10, 10, 256, endpoint=True) 9 y = np.arctan(x) 10 y = (2/np.pi) * y 11 plt.plot(x, y, color='blue', linewidth=2.0, linestyle='-') 12 13 # Set the X-axis range 14 plt.xlim (-10,10 ) 15 # is provided an X-axis scale marks, from -10 to 10, 21 to take values 16 plt.xticks (np.linspace (-10,10,21, = Endpoint True)) . 17 18 is # sets the y-axis range . 19 plt.ylim (-1,1 ) 20 is # sets the y-axis scale scale from -1 to 1, 5 values taken 21 is plt.yticks (np.linspace (- 1,1,5, Endpoint = True)) 22 is 23 is plt.show ()