[Python] Geopanadas subplots:

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am using geopandas and want three subplots. But I could not get pass the subplot axis with geopandas. I am using the geopandas 1.0.1 version.

    Here is my plotting code:

    df=pd.read_csv('/home/ruby/Desktop/degree.csv')
    gdf= gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip")
    fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(20,10))
    geometry=gpd.points_from_xy(df.lon, df.lat)
    gdf = GeoDataFrame(df, crs="EPSG:4326", geometry=geometry)
    gdf.plot(ax=axes[0],column='degree',cmap='Blues',alpha=0.6,legend=True,markersize=10,legend_kwds={'label':"Avg degree",'orientation': "horizontal"})
    gdf.plot(ax=axes[1],column='degree',cmap='Blues',alpha=0.6,legend=True,markersize=10,legend_kwds={'label':"Avg degree",'orientation': "horizontal"})
    gdf.plot(ax=axes[2],column='degree',cmap='Blues',alpha=0.6,legend=True,markersize=10,legend_kwds={'label':"Avg degree",'orientation': "horizontal"})
    plt.xlim([50.0, 130.0])
    plt.ylim([0.0,40.0])
    plt.show()


    I got the output as [​IMG]

    The csv is here :https://drive.google.com/file/d/1p1wb7iHkd2tJDGRSGZWTRJRi5StN2APK/view?usp=sharing[2]

    Continue reading...

Compartilhe esta Página