![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
matplotlib
路遥车慢
这个作者很懒,什么都没留下…
展开
-
图例画法
import matplotlib.pyplot as pltimport numpy as npx = np.arange(1,11,1)plt.plot(x,x*2,label='Normal')plt.plot(x,x*3,label='Fast')plt.plot(x,x*4,label="Faster")plt.legend()plt.show()原创 2017-05-17 16:27:04 · 358 阅读 · 0 评论 -
调整坐标轴范围
# -*- coding:utf-8 -*-# 根据需求调整坐标轴的范围import matplotlib.pyplot as pltimport numpy as npx = np.arange(-10,11,1)plt.plot(x,x*x)print(x)print(plt.axis())# plt.show()plt.axis([-6,5,0,40])plt.show()原创 2017-05-17 16:43:18 · 1430 阅读 · 0 评论 -
调整坐标刻度
# -*- coding:utf-8 -*-import matplotlib.pyplot as pltimport numpy as npx = np.arange(1,10,1)plt.plot(x,x)ax = plt.gca()# 坐标轴有多少格子刻度#ax.locator_params(nbins=5)# 只调整x轴ax.locator_params('x',nbins=5)原创 2017-05-17 17:02:37 · 601 阅读 · 0 评论 -
双坐标轴
# -*- coding:utf-8 -*-import matplotlib.pyplot as pltimport numpy as npx = np.arange(2,20,1)y1 = x*xy2 = np.log(x)fig = plt.figure()ax1 = fig.add_subplot(111)ax1.plot(x,y1)ax1.set_ylabel('Y1')ax2原创 2017-05-17 17:13:10 · 575 阅读 · 0 评论 -
画箭头提示信息
# -*- coding:utf-8 -*-import matplotlib.pyplot as pltimport numpy as np# 画提示信息x = np.arange(-10,11,1)y = x*xplt.plot(x,y)plt.annotate('this is hint',xy=(0,1),xytext=(0,20),arrowprops=dict(facecolor原创 2017-05-17 17:22:49 · 418 阅读 · 0 评论 -
画数学公式
# -*- coding:utf-8 -*-import matplotlib.pyplot as pltimport numpy as np# 画数学公式fig = plt.figure()ax = fig.add_subplot(111)ax.set_xlim([1,7])ax.set_ylim([1,5])ax.text(2,4,r"$\alpha \beta \pi \omega $原创 2017-05-17 17:51:47 · 818 阅读 · 0 评论