Home > Article > Backend Development > How to set curve style in python
##【How to set the curve style in Python: 1. Use a series of setter methods for the coordinate system; 2. Use a series of setter methods for the lines. The code is [lines = plt.plot(x,x,x ,2*x,x,x/2)】
Related learning recommendations:python tutorial】
How to set the curve style in python:
(1) Use a series of setter methods on the coordinate systemx = np.linspace(0,100,30) # 0-100要30个 x axes = plt.subplot() #获取坐标系 axes.plot(x,x,x,2*x,x,x/2) #画三条线 axes.set_title('title') #设置标题 axes.set_facecolor('gray') #设置背景色 axes.set_xlabel('x') #设置X轴标签 axes.set_ylabel('y') #设置Y轴标签Insert picture description here(2) Use a series of setter methods for lines
plt.plot()The method returns a list containing all lines
x = np.linspace(0,100,30) # 0-100要30个 x lines = plt.plot(x,x,x,2*x,x,x/2) #返回一个包含所有线的列表对象 lines[0].set_linewidth(5) #设置第一条线的宽度 lines[1].set_linestyle(':') #设置第二条线的样式 lines[2].set_color('y') #设置第三条先线的颜色
If you want to know more about related learning, please pay attention to thephp training column!
The above is the detailed content of How to set curve style in python. For more information, please follow other related articles on the PHP Chinese website!