【发布时间】:2021-03-13 23:17:27
【问题描述】:
我想知道如何从floating_axes 中的matplotlib 中删除框架。 I am following the setup_axes1 function from the matplotlib gallery here to rotate a plot.
代码贴在下面。
def setup_axes1(fig, rect):
"""
A simple one.
"""
tr = Affine2D().scale(2, 1).rotate_deg(30)
grid_helper = floating_axes.GridHelperCurveLinear(
tr, extremes=(-0.5, 3.5, 0, 4),
grid_locator1=MaxNLocator(nbins=4),
grid_locator2=MaxNLocator(nbins=4))
ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)
aux_ax = ax1.get_aux_axes(tr)
return ax1, aux_ax
我尝试了以下常用方法的变体来删除ax1 或aux_ax 上的框架,但它们都不起作用。
# before adding subplot
for a in ax1.spines:
ax1.spines[a].set_visible(False)
# when adding subplot
fig.add_subplot(ax1, frameon=False)
# after adding subplot
plt.axis('off')
plt.tick_params(labelcolor='none', top=False, bottom=False, left=False, right=False)
任何帮助或建议表示赞赏!
【问题讨论】:
标签: python matplotlib subplot axes