numpy入门基础-可视化之双坐标轴
1、添加双坐标轴2、示例
演示:
1、添加双坐标轴
matplotlib
.pyplot
.twinx
(ax
=None)
matplotlib
.pyplot
.twiny
(ax
=None)
2、示例
in:
import numpy
as np
import matplotlib
.pyplot
as plt
x
=np
.arange
(2,20,1)
y1
=x
*x
y2
=np
.log
(x
)
fig
=plt
.figure
()
ax1
=fig
.add_subplot
(111)
ax1
.plot
(x
,y1
,'y',label
='Y1')
ax1
.legend
(loc
=(0,0.92))
ax2
=ax1
.twinx
()
ax2
.plot
(x
,y2
,'r',label
='Y2')
ax2
.legend
(loc
=(0,0.85))
out:
转载请注明原文地址:https://blackberry.8miu.com/read-42117.html