OBJECTIVE
- Use Matplotlib to plot the state of Texas
CODE
import pandas as pd
import numpy as np
matplotlib.use('QT4Agg')
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import Normalize
from matplotlib.collections import PatchCollection
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
map = Basemap(projection='merc', lat_0 = 57, lon_0 = -135,
resolution = 'h', area_thresh = 0.1,
llcrnrlon=-106.65, llcrnrlat=25.83,
urcrnrlon=-93.50, urcrnrlat=36.50)
map.drawcoastlines()
map.drawstates()
map.drawcountries()
map.fillcontinents(color = 'white')
map.drawmapboundary()
plt.show(block = False)
OUTPUT
DEBUG
Apparently changing backend helps, however
matplotlib.use('QT4Agg')
yields the following error"Gtk* backend requires pygtk to be installed"
Looked online for solutions, read you had to install PyGTK, however, when installing, I receive the following error:
Building PyGTK using distutils is only supported on windows.
(after inputtingpip install PyGTK
)Additionally, despite calling
matplotlib.use('QT4Agg')
, I receive the errormatplotlib.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.
.
ISSUE
- Cannot properly install packages necessary to prevent matplotlib from running in a continual loop. Am I missing something here? Are there workarounds?
- Why, despite calling
matplotlib('QT4Agg')
before importing matplotlib, I receive the error (bullet point #3) listed above?