Reputation: 81
So I'm trying to write a piece of code that creates a figure, but in order for it to run on the computer that I want it to (school one), I can't use the x-window backend to create the figure. I tried switching the backend use (I have the matplotlib.use('Agg') statement in my code), but whenever it creates the figure, it gives me 3 colorbars on the figure when I just want one. It also gives me the error
UserWarning: This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
warnings.warn(_use_error_msg)
My code starts like this:
import matplotlib
matplotlib.use('Agg')
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from pylab import *
Any ideas or help?
Upvotes: 8
Views: 10259
Reputation: 135
Late reply, but I wanted to document this for anyone else.
You're likely using Spyder as your python interface. When you start Spyder it automatically loads those modules, hence the error about how it's already been chosen. There's a link here that explains it: https://groups.google.com/forum/#!topic/spyderlib/tRwgqEAIyvs
Upvotes: 8