【问题标题】:Place pie charts on a map using Basemap使用 Basemap 在地图上放置饼图
【发布时间】:2014-08-10 01:08:28
【问题描述】:

我想使用 Basemap 和 Matplotlib 在地图上绘制饼图。

你知道怎么做吗?

【问题讨论】:

    标签: python map matplotlib charts matplotlib-basemap


    【解决方案1】:

    您可以使用 inset_axes 将坐标区添加到底图。我已经修改了第一个示例 here 以包含一个饼图。

    from mpl_toolkits.basemap import Basemap
    from mpl_toolkits.axes_grid1.inset_locator import inset_axes
    import matplotlib.pyplot as plt
    
    # setup Lambert Conformal basemap.
    fig = plt.figure()
    ax = fig.add_subplot(111)
    m = Basemap(width=12000000,height=9000000,projection='lcc',
                resolution='c',lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.,ax=ax)
    # draw coastlines.
    m.drawcoastlines()
    # draw a boundary around the map, fill the background.
    # this background will end up being the ocean color, since
    # the continents will be drawn on top.
    m.drawmapboundary(fill_color='aqua')
    # fill continents, set lake color same as ocean color.
    m.fillcontinents(color='coral',lake_color='aqua')
    
    axin = inset_axes(m.ax,width="30%",height="30%", loc=3)
    axin.pie([100,200,3000])
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-14
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 1970-01-01
      • 2013-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多