在Matplotlib中删除直线/轴

在Matplotlib中删除直线/轴,matplotlib,grid,line,axis,Matplotlib,Grid,Line,Axis,如何去掉图表中的最后两行(水平、垂直)。 我尝试了各种不同的方法,如下所示,但这两种方法都保持不变。 有人能告诉我代码有缺陷的方向吗 plot坐标是Prince调用的一种方法,用于将ca的结果打印为matplotlib ax = ca.plot_coordinates( X=X, ax=None, marker = "o", color='k', figsize=(32, 18), x_component=0, y_component=1,show_row_labels=Fa

如何去掉图表中的最后两行(水平、垂直)。 我尝试了各种不同的方法,如下所示,但这两种方法都保持不变。 有人能告诉我代码有缺陷的方向吗

plot坐标是Prince调用的一种方法,用于将ca的结果打印为matplotlib

ax = ca.plot_coordinates(
X=X,
ax=None,
marker = "o",
color='k',
figsize=(32, 18),
x_component=0,
y_component=1,show_row_labels=False,show_col_labels=False,
)
ax.set_axis_off()
ax.get_figure().gca().set_title("")
ax.grid(False)

ax.get_legend().remove()
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])

ax.get_figure ()

我不知道这个库,但我对代码的快速分析表明,这些行是硬编码的:

调用,它依次绘制这两条线,无论您是否需要它们():

ax.axhline(y=0,线型='-',线宽=1.2,颜色=灰色['dark'],alpha=0.6)
ax.axvline(x=0,线型='-',线宽=1.2,颜色=灰色['深色',alpha=0.6)
谢天谢地,这样创建的艺术家应该存储在
ax.lines
中,因此您应该能够删除其中的前两行:

del ax.line[:2]

你是我的英雄!我从没想过要检查王子密码。这工作做得很好!非常感谢。需要更多的“声誉来提升你”——但这是有记录的!