Matplotlib绘制外部情节(两个尺度)

时间:2015-07-10 07:15:24

标签: python matplotlib plot

this问题中,我尝试在绘图外绘制一个矩形。在你的帮助下我得到了这个运行,但现在我遇到问题,如果我使用两个比例轴:

import numpy as np
import matplotlib.pyplot as plt

fig, ax1 = plt.subplots()
t = np.arange(0.01, 10.0, 0.01)
s1 = np.exp(t)
ax1.plot(t, 'b-')
ax1.set_xlabel('Query sequence')
ax1.set_ylabel('siRNA counts', color='b')
# Make the y-axis label and tick labels match the line color.
ax1.set_ylim([0, 25])
for tl in ax1.get_yticklabels():
    tl.set_color('b')


ax2 = ax1.twinx()
ax2.plot([1,20,30,40], [0.09,0.5,0.1,0.3], 'r.')
ax2.set_ylabel('Pair probabilities', color='r')
ax2.set_ylim([0.0, 1.0])
for tl in ax2.get_yticklabels():
    tl.set_color('r')

someX, someY = 5.5, -5.3
currentAxis = fig.gca()
tri = Rectangle((someX - 5.1, someY - 5.1), 5.005, 5.2, fill='b', alpha=1)
currentAxis.add_patch(tri)
tri.set_clip_on(False)

plt.show()

矩形不会再出现。非常感谢任何帮助。 感谢

0 个答案:

没有答案