2

I have been having trouble getting the figures from the example provided in Geopandas Gallery examples. When I ran these scripts in Jupyter console:

import geopandas
import geoplot
import matplotlib.pyplot as plt

world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
africa = world.query('continent == "Africa"')
ax = geoplot.cartogram(africa, scale='pop_est', limits=(0.2, 1), edgecolor='None', figsize=(7, 8))
geoplot.polyplot(africa, edgecolor='gray', ax=ax)

I will only get the this output:

<matplotlib.axes._subplots.AxesSubplot at 0x7f31fff31d30>

I have tried including the %matplotlib inline at the beginning of my Jupyter console, and I also have tried plt.show() at the end of the script. However, my console did not display the figure. I am looking into getting this figure:

enter image description here

Does someone have an idea to visualize the output a matplotlib.axes._subplots.AxesSubplot object?

I am on an Anaconda bundle using: Python 3.6, Geopandas 0.5.1, Matplotlib 3.1.1

  • In which Jupyter console did you run this? The plain terminal (not the notebook)? Doing a plt.show() manually should in principle always show the figure, and a %matplotlib should activate the automatic display (note: in the terminal it is not %matplotlib inline but just %matplotlib). – joris Aug 11 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.