Where are you running the code — Jupyter Notebook or the command line?

In Jupyter Notebook, we need to restart the kernel before setting a new backend via matplotlib.use(), otherwise it will trigger the warning This call to matplotlib.use() has no effect because the backend has already been chosen. Additionally, to avoid the warning matplotlib.use() must be called *before* pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time, we must call matplotlib.use() before importing matplotlib.pyplot.

I’ve updated my article to include my complete code. Hope it helps!

Data scientist & computer science PhD student. I write about my fun projects, in addition to how-to guides that help you get data for your own fun projects!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store