Forums

Has anyone been able to draw a map with Cartopy?

I have set up a Python 3.6 virtual environment and have managed to install matplotlib and cartopy (after compiling Proj4 library as described https://www.pythonanywhere.com/forums/topic/9366/).

In a Jupyter notebook, I can import the following with no problem:

%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

And I can draw the following simple plot successfully:

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plt(range(100))
plt.show()

However, if I run:

fig = plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
plt.show()

...the kernel crashes but does not provide any feedback to indicate what the problem might be. (I can run the same code on an Anaconda installation on my desktop and it works fine.) Any suggestions how I can get this to work on PythonAnywhere?

Hmm, that's a tricky one. What happens if you try to run the same code from a console? It won't work, of course, because there's nowhere to show the plot, but perhaps if it crashes before then it would give a more useful error message.