擅长:python、mysql、java
<p>试试这个,取自:<a href="http://matplotlib.org/examples/api/two_scales.html" rel="nofollow">http://matplotlib.org/examples/api/two_scales.html</a>
我把我的例子放在下面。在</p>
<p>我只是建立了一些指数增长的数据集。当然,可以更精确地调整坐标轴,比如创建自己的刻度、范围和刻度线;您所要做的就是花一些时间在网上做示例并阅读API文档。另外,我将为您指出这个参考资料<a href="http://nbviewer.ipython.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb" rel="nofollow">http://nbviewer.ipython.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb</a>中的一些好例子。在</p>
<pre><code>from numpy import *
import matplotlib.pyplot as plt
x_data = arange(0,100,.1)
y1_data = x_data**10
y2_data = x_data**4
fig, ax1 = plt.subplots(nrows=1, ncols=1)
ax1.set_yscale('linear')
ax1.plot(x_data,y1_data,'b-')
ax1.set_xlabel("Unitless X's")
ax1.set_ylabel('Linear Scale', color='b')
for tl in ax1.get_yticklabels():
tl.set_color('b')
ax2 = ax1.twinx()
ax2.plot(x_data,y2_data,'r.')
ax2.set_ylabel("Log Scale", color='r')
ax2.set_yscale('log')
for tl in ax2.get_yticklabels():
tl.set_color('r')
plt.show()
</code></pre>