FAQs = (
('NUMARRAY',
'Does matplotlib work with numarray?',
"""
Yes. Todd Miller has added a numerix module which allows you to
choose between Numeric or numarray at the promptw, in a config file,
or using an environment variable. For the most part, this works
seamlessly. See numerix module for more
information.
"""),
('MATPLOTLIBRC',
'How do I customize the default behavior of matplotib?',
"""
Recent versions of matplotlib (0.51 or later) use a configuration file
to set everything from the default font, to the figure size, to the
default line width. See .matplotlibrc for a
sample config file and information on how to use it. """),
('CUSTOM',
'How do I customize the default behavior of a single figure?',
r"""
If you want to customize a single figure, eg, the default font,
linewidth, fontsize, etc, you can import and customize the rcParams
determined by the matplotlibrc file (see above). For example, if you
are using mathtext you may want your default axes labels, tick labels
etc, to be in the same font as mathtext roman.
from matplotlib import rcParams # default font is computer modern roman and linewidth is 1.0 rcParams['text.fontname'] = 'cmr10' rcParams['lines.linewidth'] = 2.0 from matplotlib.matlab import * plot([1,2,3]) title(r'$\rm{Histogram of IQ:} \mu=100, \sigma=15$') show()"""), ('GTKPATH', 'I cannot import gtk / gdk / gobject', """ Basically, there are 3 things that I've seen cause failure (relative likelihood in parentheses):
For publication submission or use with TeX, however, the postscript backend is naturally a good choice.
figure(figsize=(6,4)) plot(blah, blah) savefig('myfile', dpi=75)See ttf fonts for more information. """ ), ('SHOW', "What's up with 'show'? Do I have to use it?", """ The use of show is probably the biggest source of confusion and vexation among new users of matplotlib. First of all, you do not need this function with the image backends (Agg, Paint, GD, PS) but you do need it with the GUI (GTK, WX, TkAgg, GTKAgg) backends, unless you are running matplotlib in interactive mode.
Because it is expensive to draw, I want to avoid redrawing the figure many times in a batch script such as the following
plot([1,2,3]) # draw here ? xlabel('time') # and here ? ylabel('volts') # and here ? title('a simple plot') # and here ? show()It is possible to force matplotlib to draw after every command, which is what you want in interactive mode, but in a script you want to defer all drawing until the script has executed. This is especially important for complex figures that take some time to draw. 'show' is designed to tell matplotlib that you're all done issuing commands and you want to draw the figure now. In the TkAgg backend, which can be used from an arbitrary python shell interactively, it also sets interactive mode. So you can launch your script with python -i myscript.py -dTkAgg and then change it interactively from the shell."""), ('PSGUI', 'Can I save PS/EPS from a GUI backend?', """ Yep. Just choose a filename that contains ps in the extension, eg somefile.ps or somefile.eps and matplotlib will try and do the right thing. That is, if it's an eps file, it will include a bounding box, if it's a ps file it will output plain postscript. It is recommended you use matplotlib-0.50 or later for this feature to work properly."""), ('TEXTOVERLAP', 'My title or ticklabel or whatever is overlapping some other figure element, what should I do?', """ The default subplots take up a lot of room. If you need extra space for particularly large labels and titles, consider using custom axes, eg, axes([0.3, 0.3, 0.6, 0.6]) gives you more room to the left and at the bottom than the standard axes. Other things to consider. With multiple subplots, eg, multiple rows, turn off the xticklabels for all but the lowest subplot if they are the same in all subplots set(gca(), 'xticklabels', []). You can make the fontsizes smaller, as in xlabel('time (s)', fontsize=8) or, for the tick labels
t = gca().get_xticklabels() set(t, 'fontsize', 8)You can also set the default ticklabel size in your matplotlibrc file or override it for a single plot using rcParams."""), ('DYNAMIC', 'Can matplotlib do dynamic plots, like digital oscilloscopes or animations?', """ Absolutely. See for example, anim.py and system_monitor.py"""), ('PERFORMANCE', 'Is matplotlib fast enough for very large data sets?', """ The answer, of course, is "it depends". I've worked hard to make matplotlib work well with very large data sets (100s of MB), because these are the kinds of data I need to handle at work. It is very good at handling data sets where the x axis is contiguous (eg, time) and only a small portion of data in displayed in the viewport; see for example stock_demo.py where you can scroll through 2 months of minute-by-minute stock quote data.
from matplotlib.matlab import * plot([1,2,3,4], [1,4,9,16]) set(gca(), 'xticks', [1,2,3,4]) labels = set(gca(), 'xticklabels', ['Frogs', 'Hogs', 'Bogs', 'Slogs']) set(labels, 'rotation', 'vertical') show()"""), ('WINFONTS', "On windows with GTK, I'm getting lots of messages about not finding the Times font", r""" Apparently GTK changed the default pango font file, because this is a new problem. You can set font aliases in C:\GTK\etc\pango\pango.aliases. Add a line like
times = "times new roman,angsana new,mingliu,simsun,gulimche,ms gothic,latha,mangal,code2000"""" ), ('FONTCACHE', "On windows with GD/Agg/Paint, the first time I ran my script I got a bunch or error messages but don't anymore", """ These modules use FontTools and TTFQuery to find freetype fonts. The first time you import one of these backends, a font registry created in site-packages/ttfquery/font.cache. As you system is scanned for fonts, some errors may be caught if a font file is not readable, etc. Generally, this is not a major problem, as long as most system fonts are found. In subsequent runs, the font.cache is already built so you won't see the messages again. If you want to see the error messages, remove font.cache and rerun your script, capturing them to a file. """ ), ('FREETYPE2', "Why are my fonts not being rendered properly?", """ This is probably due to an outdated freetype2 library. The latest version is 2.1.8. See font manager docs for details. """ ), ) @header@
- @footer@