代码之家  ›  专栏  ›  技术社区  ›  generic_user

用python绘制一组简单的叶绿体图-颜色不显示

  •  0
  • generic_user  · 技术社区  · 6 年前

    这是一个我正试图绘制的形状文件:

    link to a zipped shapefile

    假设我要映射列 liab . 我可以看到它有一个值分布:

    import geopandas as gpd
    import matplotlib.pyplot as plt
    foo = gpd.read_file("foo.shp")
    plt.hist(foo.liab)
    

    enter image description here

    但当我试图绘制它们时,我看不到任何颜色:

    foo.plot(column = "liab", legend = True)
    

    enter image description here

    怎么了?

    最后,我想做一个地图网格,类似于 facet_wrap 在里面 ggplot2 在r中,是否有python模拟?

    0 回复  |  直到 6 年前
        1
  •  1
  •   Paul H    6 年前

    我不能告诉你为什么,但是你需要指定你 vmin|max 对于彩色地图。我以为geopandas是自动完成的,举个小例子,但不是你的shapefile:

    import geopandas
    
    ax = (
        geopandas.read_file('/mnt/c/users/phobson/downloads/foo/foo.shp')
            .to_crs({'init': 'epsg:3083'})
            .plot(column="liab", legend=True, figsize=(10, 4),
                  vmin=0.0, vmax=1)  # <-- magic is here
    )
    

    enter image description here