我想修改MPL example每列和y每行共享x和我喜歡把在y刻度標記的右側。 我試過類似this一個解決方案,即Y標誌在matplotlib陰謀右側與共享x和y
import matplotlib.pyplot as plt
import numpy as np
# Simple data to display in various forms
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
plt.close('all')
# row and column sharing
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row')
ax1.plot(x, y)
ax1.set_title('Sharing x per column, y per row')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
ax4.plot(x, 2 * y ** 2 - 1, color='r')
#my "contribution" to the code:
for ax in [ax1,ax3]:
ax.yaxis.set_ticks_position('both')
ax.set_yticklabels([])
for ax in [ax2,ax4]:
ax.yaxis.set_ticks_position('both')
ax.yaxis.tick_right()#right hand side tickslabels
plt.show()
這對於一個情節的作品,而不是在這裏:沒有Ÿ刻度標記的。 建議?將x標籤放在最前面的同樣的問題。
如果我只用第二個循環,我得到的第一列和至少右手y側刻度標記輸出例如在第二列,但左側蜱在第二列中消失。爲什麼會發生?
請提供完整的最簡單示例。這將使它更容易helpp。 – hitzg 2015-02-24 15:12:10
@hitzg在這裏你去,但正如我上面鏈接,它只是複製從[matplotlib演示]貼(http://matplotlib.org/examples/pylab_examples/subplots_demo.html)加我2 for循環。 – mikuszefski 2015-02-25 13:44:06