摆脱框架和轴标签

2024-09-27 00:16:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一些研究,但我发现的每个解决方案都不适用于“Anaconda-2.2.0-Linux-x86_.sh”。。。有人能告诉我如何摆脱框架和轴标签吗?你知道吗

boros = GeoDataFrame.from_file('nybb/nybb.shp') 
boros.plot()

enter image description here


Tags: from框架plotlinuxshanaconda标签解决方案
1条回答
网友
1楼 · 发布于 2024-09-27 00:16:23

以下是移除脊椎和勾号标签的方法:

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

x = np.linspace(-np.pi, np.pi, 100)
y = 2*np.sin(x)

ax.plot(x, y) 

ax.patch.set_visible(False)
ax.grid('off')

[ax.spines[spine].set_visible(False) for spine in ax.spines]

ax.set_xticklabels([]);
ax.set_yticklabels([]);

plt.show()

enter image description here

请注意,调用.plot()时,需要将引用传递给将放置绘图的axes对象,如.plot(ax=ax)。你知道吗

如果没有引用axes对象的变量,则可以使用plt.gca()访问当前轴。你知道吗

相关问题 更多 >

    热门问题