The answer to your second question is a little more involved and I think there are a few posts regarding custom colormaps on the mailing list that may be of interest...I'd try searching through those.  I may not be the best person to answer that question. 

Also you may be interested in exploring the *kwargs vmin and vmax of the imshow command.  They may do what you need as well:

As for your first question try the following in ipython with the -pylab flag:

import numpy as N
a = N.random.rand(50)
ax = gca()
ax.set_xlim(0,25) #  The set_xlim and set_ylim may be what you're looking for...

--- On Mon, 12/29/08, Christian Lerrahn <> wrote:
From: Christian Lerrahn <>
Subject: [Matplotlib-users] Manually limiting value ranges
Date: Monday, December 29, 2008, 11:19 PM

I've been trying to do this for a while but just can't get it to
work. :(

There are 2 things I want to do.

1. I want to limit the value range in a line plot from
matplotlib.pyplot.plot(). I thought that clip_box would do exactly
that but setting something like [[-1,1],[-5,5]] or the like doesn't
seem to have any effect.

2. In a 2D map plot from matplotlib.pyplot.imshow(), I would like to
set the limits for the colour bar manually. I.e. I want the colours to
be equally distributed over a fixed range.

In both cases, the background to my attempt of using fixed values is
that I'm producing a time series of plots via script and want all the
plots to be directly comparable.

Did I overlook this in the examples (or the documentation) or is there
really no simple way of doing this?


Matplotlib-users mailing list