近来学习了下python matplotlib绘图,其功能還是很强大的。
由于需要在一张图上展示多个子图,所以用到subplot,python 绘制这种图的方式有很多種,这里介紹其中一种方法:
1.第一种画图plt.subplots()
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
plt.style.use('ggplot') #可以绘制出ggplot的风格
# 给出x,y值
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
#只画一个图
f, ax = plt.subplots()
ax.set_title('Simple sin_plot')
ax.plot(x, y)
plt.show()
p1= r'E:\vpn\test1.png'