[英]Python Matplotlib error when using matplotlib.axis.XAxis.set_ticks_position('bottom')
我正在使用面向Python的Enthought IDE,並且正在使用matshow繪制一個名為recmat的矩陣。 Matshow將xlab繪制在圖的頂部,我希望它們在底部。 下面的代碼導致此錯誤消息:
TypeError:set_ticks_position()缺少1個必需的位置參數:“ position”
plt.matshow(recmat)
matplotlib.axis.XAxis.set_ticks_position('bottom')
plt.colorbar()
plt.show()
我怎樣才能解決這個問題? 還是有另一種移動標簽的方法? 非常感謝你的幫助!
您需要為當前軸調用xaxis.tick_bottom()
,如下所示:
import numpy as np
import matplotlib.pyplot as plt
recmat = np.random.random((100,100))
plt.matshow(recmat)
ax = plt.gca()
plt.colorbar()
ax.xaxis.tick_bottom()
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.