pandas折线图x轴显示不全_python - 为什么在Geopandas中显示折线图时会忽略绘图顺序 - 堆栈内存溢出...

作为我正在从事的社区项目的一部分,我一直在试验geopandas和从openstreetmaps导出的一些数据。 为了试用数据可视化方面,我导出了一部分城镇的数据,并使用geopandas对其进行了绘制。 这行之有效,只是不管我绘制图层的顺序如何,道路图层都将显示在其他所有图层之上。

我尝试使用谷歌搜索解决方案,并且每一个都指示您执行绘图的顺序应决定分层,最后要绘制的内容显示在其他所有内容之上。 应用此逻辑,道路线应位于建筑物和欺骗的gps定位点之下? 有人可以建议我如何解决此问题,以便可以控制最上一层吗?

import matplotlib.pyplot as plt

import geopandas as gpd

import numpy as np

# import and clean up map data

derby_roads = gpd.read_file('map/roads.geojson')

derby_roads_clean = derby_roads[derby_roads.highway.str.contains('motorway|trunk|primary|secondary|tertiary|residential')]

derby_buildings = gpd.read_file('map/buildings.geojson')

#print(derby_roads_clean)

#print(derby_buildings.head())

# generate random gps data

# min x -1.4879, max x -1.4407

# min y 52.8801, max y 52.8962

points_x = np.random.uniform(-1.4879, -1.4407, size = (50,))

points_y = np.random.uniform(52.8801, 52.8962, size = (50,))

points_z = np.random.uniform(0, 100, size = (50,))

gdf = gpd.GeoDataFrame(points_z, geometry=gpd.points_from_xy(points_x,points_y))

print(gdf.head())

# Create Matplotlib figure

fig, ax = plt.subplots()## configure axis

ax.set_aspect('equal')

ax.set_frame_on(False)

ax.get_xaxis().set_ticks([])

ax.get_xaxis().set_ticklabels([])

ax.get_yaxis().set_ticks([])

ax.get_yaxis().set_ticklabels([])

# plot map data

derby_roads.plot(ax=ax, color='#e6e6e6')

derby_roads_clean.plot(ax=ax, color='grey')

derby_buildings.plot(ax=ax, color='#000000')

gdf.plot(ax=ax, color='red')

#mng = plt.get_current_fig_manager()

#mng.full_screen_toggle()

plt.tight_layout()

plt.show()

你可能感兴趣的:(pandas折线图x轴显示不全)