标签:hand nes 修改 import otl ble color numpy 字体
一、普通绘图
1 import matplotlib.pyplot as plt 2 import numpy as np 3 4 # 绘制普通图像 5 x = np.linspace(-1, 1, 50) 6 y1 = 2 * x + 1 7 y2 = x**2 8 9 plt.figure() 10 # 在绘制时设置lable, 逗号是必须的 11 l1, = plt.plot(x, y1, label = ‘line‘) 12 l2, = plt.plot(x, y2, label = ‘parabola‘, color = ‘red‘, linewidth = 1.0, linestyle = ‘--‘) 13 14 # 设置坐标轴的取值范围 15 plt.xlim((-1, 1)) 16 plt.ylim((0, 2)) 17 18 # 设置坐标轴的lable 19 plt.xlabel(‘X axis‘) 20 plt.ylabel(‘Y axis‘) 21 22 # 设置x坐标轴刻度, 原来为0.25, 修改后为0.5 23 plt.xticks(np.linspace(-1, 1, 5)) 24 # 设置y坐标轴刻度及标签, $$是设置字体 25 plt.yticks([0, 0.5], [‘$minimum$‘, ‘normal‘]) 26 27 # 设置legend 28 plt.legend(handles = [l1, l2,], labels = [‘a‘, ‘b‘], loc = ‘best‘) 29 plt.show()
标签:hand nes 修改 import otl ble color numpy 字体
原文地址:https://www.cnblogs.com/hoojjack/p/9823410.html