先上效果图:
图一

基本操作,指定坐标轴范围
import matplotlib.pyplot as plt
import numpy as np
x_value=np.linspace(1,10)
y_value=np.sin(x_value)
plt.axis([1,10,-1,1])
plt.xlabel("x")
plt.ylabel("sin(x)")
plt.plot(x_value,y_value)
#plt.savefig("G:\Pictures\Figure_1.png")
plt.show()
图二

子图模式
plt.subplot(nrows, ncols, plot_number)
在全局绘图区域中创建一个nrows*ncols的分区体系,并定位到第plot_number个子绘图区域,区域计数从1开始。
图三

格式控制
import matplotlib.pyplot as plt
import numpy as np
x_value=np.linspace(1,10)
y_value=np.sin(x_value)
plt.plot(x_value,y_value,"b-")
plt.plot(x_value,y_value,"r *")
plt.show()
plt.plot(x, y, format_string, **kwargs)
| 参数 | 含义 |
|---|---|
| x | X轴数据,列表或数组,可选 |
| y | Y轴数据,列表或数组 |
| format_string | 控制曲线的格式字符串,可选 |
| **kwargs | 第二组或更多(x,y,format_string) |
当绘制多条曲线时,各条曲线的x不能省略
关于format_string

format_string颜色字符

format_string风格字符

format_string标记字符
关于**kwargs

可选参数列表