gboeing / ppde642

USC urban data science course series with Python and Jupyter
https://geoffboeing.com
MIT License
1.26k stars 487 forks source link

Basemap plotting #5

Closed shriv closed 6 years ago

shriv commented 6 years ago

I've been trying to run /notebooks/urban-data-science/20-Accessibility-Walkability/pandana-accessibility-demo-full.ipynb. The first plot cell [22] is not working. The initial error was due to basemap not being installed. I separately went and installed basemap with conda. Once that was done, I now get a different error and an empty plot box.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-5de67c376af3> in <module>()
      2 n = 1
      3 bmap, fig, ax = network.plot(all_access[n], bbox=bbox, plot_kwargs=plot_kwargs, fig_kwargs=fig_kwargs, 
----> 4                              bmap_kwargs=bmap_kwargs, cbar_kwargs=cbar_kwargs)
      5 ax.set_axis_bgcolor(bgcolor)
      6 ax.set_title('Walking distance (m) to nearest amenity around Berkeley/Oakland', fontsize=15)

/home/shrividya/anaconda2/lib/python2.7/site-packages/pandana/network.pyc in plot(self, data, bbox, plot_type, fig_kwargs, bmap_kwargs, plot_kwargs, cbar_kwargs)
    440             bbox[1], bbox[0], bbox[3], bbox[2], ax=ax, **bmap_kwargs)
    441         bmap.drawcoastlines()
--> 442         bmap.drawmapboundary()
    443 
    444         x, y = bmap(self.nodes_df.x.values, self.nodes_df.y.values)

/home/shrividya/anaconda2/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in drawmapboundary(self, color, linewidth, fill_color, zorder, ax)
   1621         # if fill_color is string 'none', really don't fill.
   1622         if fill_color is None:
-> 1623             fill_color = ax.get_axis_bgcolor()
   1624         elif fill_color == 'none' or fill_color == 'None':
   1625             fill_color = None

AttributeError: 'AxesSubplot' object has no attribute 'get_axis_bgcolor'
shriv commented 6 years ago

The fix is according to this: https://stackoverflow.com/questions/49469409/basemap-attribute-python Happy for this issue to be closed since there is a workaround.