python plt_python plt.plot怎么把图显示出来?
展开全部
1, 导入matplotlib.pyplot, numpy 包:2113
import numpy as np
import matplotlib.pyplot as plt
2,添加主题样式:
plt.style.use('mystyle')
3, 设置图的大5261小,添加子图:4102
fig = plt.figure(figsize=(5,5))
ax = fig.add_subplot(111)
4,绘制1653sin, cos:
x = np.arange(-np.pi, np.pi, np.pi / 100)
y1 = np.sin(x)
y2 = np.cos(x)
sin, = ax.plot(x, y1, color='red', label='sin')
cos, = ax.plot(x, y2, color='blue', label='cos')
ax.set_ylim([-1.2, 1.2])
第二种方式 拆分显示
sin_legend = ax.legend(handles=[sin], loc='upper rig
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
