matplotlib_200730系列---13、次坐标轴
matplotlib_200730系列---13、次坐标轴
一、总结
一句话总结:
I、ax2=axl.twinx(); #Create a twin Axes sharing the xaxis
II、axl.plot(x,y1,'g-'); ax2.plot(x,y2,'b--');
import matplotlib.pyplot as plt import numpy as np x=np.arange(0,10,0.1) y1=0.05*x**2 y2=-1*y1 fig,axl=plt.subplots() # 镜像 # Create a twin Axes sharing the xaxis ax2=axl.twinx() axl.plot(x,y1,'g-') ax2.plot(x,y2,'b--') axl.set_xlabel('X data') axl.set_ylabel('Y1', color='g') ax2.set_ylabel('Y2', color='b') plt.show()
二、次坐标轴
博客对应课程的视频位置:
import matplotlib.pyplot as plt import numpy as np x=np.arange(0,10,0.1) y1=0.05*x**2 y2=-1*y1 fig,axl=plt.subplots() # 镜像 # Create a twin Axes sharing the xaxis ax2=axl.twinx() axl.plot(x,y1,'g-') ax2.plot(x,y2,'b--') axl.set_xlabel('X data') axl.set_ylabel('Y1', color='g') ax2.set_ylabel('Y2', color='b') plt.show()
版权申明:欢迎转载,但请注明出处
一些博文中有一些参考内容因时间久远找不到来源了没有注明,如果侵权请联系我删除。
在校每年国奖、专业第一,加拿大留学,先后工作于华东师范大学和香港教育大学。
2024-09-05:27岁,宅加太忙,特此在网上找女朋友,vx:fan404006308
AI交流资料群:753014672