gpt4 book ai didi

python - 如何减少 Python 绘图中的空白?

转载 作者:行者123 更新时间:2023-12-01 02:08:57 25 4
gpt4 key购买 nike

我正在使用它绘制 2 个 shapefile(转换为 geopandas 数据框)。但空白太多了。如何减少它以便用 map 更多地填充该框? xlimylim 似乎没有任何影响

f, ax = plt.subplots(1, figsize=(8, 8))
polydatx.plot(ax = ax, column = 'Elev_Avg', cmap='OrRd', scheme='quantiles')
segdatx.plot(ax = ax)
ax.grid(False)
ax.set_ylim(47, 47.3)
plt.axis('equal');

enter image description here

最佳答案

问题出在调用

plt.axis('equal')

设置新的ylim后。

来自docs :

axis('equal') changes limits of x or y axis so that equal increments of x and y have the same length; a circle is circular.:

axis('scaled') achieves the same result by changing the dimensions of the plot box instead of the axis data limits.

在你的情况下,我会将图形大小调整为某个矩形,而不是正方形,并使用axis('scaled')

关于python - 如何减少 Python 绘图中的空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48833211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com