PANDAS绘制多个Y轴

我知道pandas支持第二个Y轴,但我好奇,如果有人知道一个方法来把第三个Y轴放在地块上…目前我正在用numpy + pyplot来实现这一点…但是对于大型数据集来说这是很慢的。

这是为了便于比较(例如相对湿度/温度/和电导率),在同一graphics上用不同的单位绘制不同的测量值,

所以真的只是好奇,如果有人知道如果这是可能的pandas没有太多的工作。

[编辑]我怀疑有没有办法做到这一点(没有太多的开销),但是我希望被certificate是错误的,这可能是matplotlib的限制…

我认为这可能工作:

 import matplotlib.pyplot as plt import numpy as np from pandas import DataFrame df = DataFrame(np.random.randn(5, 3), columns=['A', 'B', 'C']) fig, ax = plt.subplots() ax3 = ax.twinx() rspine = ax3.spines['right'] rspine.set_position(('axes', 1.15)) ax3.set_frame_on(True) ax3.patch.set_visible(False) fig.subplots_adjust(right=0.7) df.A.plot(ax=ax, style='b-') # same ax as above since it's automatically added on the right df.B.plot(ax=ax, style='r-', secondary_y=True) df.C.plot(ax=ax3, style='g-') # add legend --> take advantage of pandas providing us access # to the line associated with the right part of the axis ax3.legend([ax.get_lines()[0], ax.right_ax.get_lines()[0], ax3.get_lines()[0]],\ ['A','B','C'], bbox_to_anchor=(1.5, 0.5)) 

输出:

产量