[英]Matplotlib: Turning axes off and setting facecolor at the same time not possible?
有人可以解釋為什么這個簡單的代碼在設置軸關閉時不會執行 facecolor 命令嗎?
fig = plt.figure(1)
ax = fig.add_subplot(211, facecolor=(0,0,0), aspect='equal')
ax.scatter(np.random.random(10000), np.random.random(10000), c="gray", s=0.25)
ax.axes.set_axis_off()
提前致謝!
背景補丁是軸的一部分。 因此,如果軸關閉,背景補丁也將關閉。
一些選項:
ax = fig.add_subplot(211, facecolor=(0,0,0), aspect='equal')
ax.set_axis_off()
ax.add_artist(ax.patch)
ax.patch.set_zorder(-1)
ax = fig.add_subplot(211, facecolor=(0,0,0), aspect='equal')
ax.set_axis_off()
ax.add_patch(plt.Rectangle((0,0), 1, 1, facecolor=(0,0,0),
transform=ax.transAxes, zorder=-1))
...但保持軸打開。
ax = fig.add_subplot(211, facecolor=(0,0,0), aspect='equal')
for spine in ax.spines.values():
spine.set_visible(False)
ax.tick_params(bottom=False, labelbottom=False,
left=False, labelleft=False)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.