我使用 matplotlib.pyplot 创建了一个子图。即使我使用以下方法将刻度标签设置为空:
plt.xticks([ ])
plt.yticks([ ])
Run Code Online (Sandbox Code Playgroud)
我怎样才能删除这些?我是 Python 新手,非常感谢有关此事的任何帮助。
你的人物图里有很多次要情节。您需要删除每个子图的每个轴对象中的刻度(或者至少是您希望出现的刻度)。这可以这样做:
import matplotlib.pyplot as plt
ax1 = plt.subplot(321) # 1st subplot in 3-by-2 grid
ax1.plot(...) # draw what you want
ax1.set_xticks([], []) # note you need two lists one for the positions and one for the labels
ax1.set_yticks([], []) # same for y ticks
ax2 = plt.subplot(321) # 2nd subplot in the same grid
# do the same thing for any subplot you want the ticks removed
Run Code Online (Sandbox Code Playgroud)
如果你想删除整个轴(边框、刻度线和标签),你可以这样做:
ax1.axis('off')
Run Code Online (Sandbox Code Playgroud)
不过我建议输入plt.tight_layout()
. 它可能会解决您的问题,而无需您去除蜱虫。
归档时间: |
|
查看次数: |
4313 次 |
最近记录: |