标签:sub values win append pen lse value highlight val
1、双y轴
x = np.arange(0., np.e, 0.01) y1 = np.exp(-x) y2 = np.log(x) fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(x, y1) ax1.set_ylabel(‘Y values for exp(-x)‘) ax1.set_title("Double Y axis") ax2 = ax1.twinx() # this is the important function ax2.plot(x, y2, ‘r‘) ax2.set_xlim([0, np.e]) ax2.set_ylabel(‘Y values for ln(x)‘) ax2.set_xlabel(‘Same X for both exp(-x) and ln(x)‘) plt.show()
2、分段画图
def sgn(value): if value < 4: return 20 else: return 15 plt.figure(figsize=(6,4)) x = np.linspace(0, 8, 100) y = np.array([]) for v in x: y = np.append(y,np.linspace(sgn(v),sgn(v),1)) l=plt.plot(x,y,‘b‘,label=‘type‘) plt.legend() plt.show()
标签:sub values win append pen lse value highlight val
原文地址:https://www.cnblogs.com/xxupup/p/12015742.html