【问题标题】:Is it possible to remove the border? [duplicate]可以去掉边框吗? [复制]
【发布时间】:2020-11-01 17:40:43
【问题描述】:

你好,我有这个使用 matplotlib 的代码:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1],[1])
ax.tick_params(axis=u'both', which=u'both', length=0)
plt.show()

但我想要这个:

我的意思是我只想删除黑色边框。

有可能吗?

非常感谢!

【问题讨论】:

标签: python python-3.x matplotlib


【解决方案1】:

使用ax.spines["top"].set_visible(False) 控制寄宿生的可见性

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1],[1])
ax.tick_params(axis=u'both', which=u'both', length=0)

ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["bottom"].set_visible(False)
ax.spines["left"].set_visible(False)
plt.show()

输出

【讨论】:

    猜你喜欢
    • 2011-10-27
    • 2011-01-24
    • 2014-08-05
    • 1970-01-01
    • 2019-11-28
    • 2011-01-17
    • 1970-01-01
    • 2013-11-11
    相关资源
    最近更新 更多