[Matplotlib-users] sharing labels and legends across subplots

2009-10-11 Thread per freem
hi all,

i am trying to share both an axis label (but not the entire axis) and
a figure legend across a set of subplots. that is, i'd like to have a
figure where there is a major enlarged ylabel that is meant to label
the entire row of subplots and a main figure legend, rather than
individual legends inside subplots. what i have right now is:

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero
fig = plt.figure()
ax = SubplotZero(fig, 3, 1, 1)
ax1 = fig.add_subplot(ax)
ax.axis["xzero"].set_visible(True)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
ax = SubplotZero(fig, 3, 1, 2)
ax2 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
ax = SubplotZero(fig, 3, 1, 3)
ax3 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.01, 3.01], label="line b", c='b')
plt.figlegend([ax1.lines[0], ax1.lines[1]], ["line a", "line b"], 'upper right')

two quick questions about this: first, how can i create a single
ylabel for the figure?  i still want each subplot to have its own
yticks and ytick labels but i just want a main label, since the
quantity plotted on each y axis is the same.

finally, plt.figlegend does display a main legend for the figure, like
i intended, but i was hoping someone can explain how ax1.lines gets
set. i was expecting ax1.lines to have 2 elements in it, one for each
line plotted, but it has 4. why is that? right now i simply used
lines[0] and lines[1] to create the labels for only the plotted
lines... is there a better way of doing this?

thanks.

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sharing labels and legends across subplots

2009-10-11 Thread Gökhan Sever
On Sun, Oct 11, 2009 at 9:07 AM, per freem  wrote:

> hi all,
>
> i am trying to share both an axis label (but not the entire axis) and
> a figure legend across a set of subplots. that is, i'd like to have a
> figure where there is a major enlarged ylabel that is meant to label
> the entire row of subplots and a main figure legend, rather than
> individual legends inside subplots. what i have right now is:
>
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid.axislines import SubplotZero
> fig = plt.figure()
> ax = SubplotZero(fig, 3, 1, 1)
> ax1 = fig.add_subplot(ax)
> ax.axis["xzero"].set_visible(True)
> plt.plot([1,2,3], label="line a", c='r')
> plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
> ax = SubplotZero(fig, 3, 1, 2)
> ax2 = fig.add_subplot(ax)
> plt.plot([1,2,3], label="line a", c='r')
> plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
> ax = SubplotZero(fig, 3, 1, 3)
> ax3 = fig.add_subplot(ax)
> plt.plot([1,2,3], label="line a", c='r')
> plt.plot([1.2, 2.01, 3.01], label="line b", c='b')
> plt.figlegend([ax1.lines[0], ax1.lines[1]], ["line a", "line b"], 'upper
> right')
>
> two quick questions about this: first, how can i create a single
> ylabel for the figure?  i still want each subplot to have its own
> yticks and ytick labels but i just want a main label, since the
> quantity plotted on each y axis is the same.
>

I had asked a similar question at
http://www.nabble.com/Common-ylabel-for-subplots-td22416664.html#a22416664

which I had managed to have a common y-label following the suggestions given
on that thread. However I haven't gone further to create a common legend.


>
> finally, plt.figlegend does display a main legend for the figure, like
> i intended, but i was hoping someone can explain how ax1.lines gets
> set. i was expecting ax1.lines to have 2 elements in it, one for each
> line plotted, but it has 4. why is that? right now i simply used
> lines[0] and lines[1] to create the labels for only the plotted
> lines... is there a better way of doing this?
>
> thanks.
>
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Gökhan
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-10-11 Thread John [H2O]


Jeff Whitaker wrote:
> 
> 
> John:  I don't have time to look at your code right now, but let me just 
> make some general comments about plotting images on maps.  If you want 
> to use imshow, the data your are plotting must coincide exactly with 
> your map plot area.  So, for example if you want to plot a global 
> lat/lon grid on a north polar stereographic projection, you have to 
> interpolate to a rectangular grid in projection coordinates that fits in 
> the map region.  However, in practice I find it's almost never worth 
> doing this.  You can plot the data in the native coordinates on almost 
> any map projection region using pcolormesh or contourf,  Just calculate 
> the x,y values of the of the data grid, and pass those values along with 
> the data to either one of those methods.  Is there any particular reason 
> you want to use imshow, instead of pcolormesh or contourf?
> 
> -Jeff
> 
> 

Jeff,

I started using pcolormesh, but ran into the problem that I really required
a log scale color map for the plotting. As I recall, this could only be done
with imshow - but perhaps that has changed? Regardless, I've done some
further testing. It seems I have the following problems with it:

1) It is much more 'coarse' in the coloring, imshow offers a finer/smoother
looking gradient. 

2) The bigger problem occurs when plotting in npstere, which I use quite
often. Maybe I have to add a wrap around, but as it is, I get a 'seam' at
the -180/180 meridian. 

3) At the pole, there is a empty spot, creating a hole in my plots. This I
can't work with... :s

Thanks again for your input.

-john 


-- 
View this message in context: 
http://www.nabble.com/basemap%2C-transform_scalar-question-tp25649437p25847646.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Images and memory management

2009-10-11 Thread Leo Trottier
Hi Michael,

I suppose I'm a bit confused --  I thought that jpeglib, part of which
is implemented by PIL (??) could process compressed images without
representing decompressing them to a dense raster-image matrix
(http://en.wikipedia.org/wiki/Jpeglib).

That said, I tried to do some PIL things, and as soon as I converted
an image (or something similar) the memory taken up suggested that the
image was represented completely and uncompressed (memory was more or
less evenly split between virtual and real memory).

So, I guess what remains are the problems with iPython.  My
MATLAB-loving friend has stuck his nose up because of the memory-leaky
interactive prompt, claiming that MATLAB has no such problems ...

Thanks for your help, in any case.

Leo

On Mon, Oct 5, 2009 at 5:47 AM, Michael Droettboom  wrote:
> For some reason, my earlier reply didn't seem to make it to the mailing
> list.  Here it is in its entirety:
>
> """
> If you assign each figure to a new number, it will keep all of those figures
> around in memory (because pyplot thinks you may want to use it again.)  The
> best route is to call close('all') or fig.close() with each loop iteration.
>
> 40MB per image doesn't sound way out of reason to me.  How big are your
> images?
> """
>
> On 10/05/2009 03:46 AM, Leo Trottier wrote:
>
> Hi,
>
> I think I've figured out what's going on.  It's a combination of things:
>
> 1) iPython is ignorant of the problems associated with caching massive data
> output
> 2) iPython doesn't seem to have a good way to clear data from memory
> reliably (https://bugs.launchpad.net/ipython/+bug/412350)
>
> iPython is designed for interactive use, and stores a lot of values so they
> can be conveniently reused later.  For long running "batch" scripts, you can
> use "regular" Python, or run the code in iPython such that it isn't
> displayed at the console (by using "import" or "%run").  Bug 2) may help
> looks like it would still require some manual intervention to be usefull.
> You're still using a tool designed for fine-grained interactive use (eg. a
> pen) where one designed for automation may be more appropriate (eg. a laser
> printer) :)
>
> 3) matplotlib/Python seems to be insufficiently aggressive in its garbage
> collection (??)
>
> Is that still true after forcibly closing the figures on each loop iteration
> as I suggested?  Many hours have been spent squashing memory leaks in
> matplotlib, and I am not aware of any in at least 0.98 and later (other than
> some unavoidable small leaks in certain GUI backends).  Do you have a
> standalone example that illustrates this on a recent version of matplotlib?
>
> 4) For obvious reasons, JPGs are much bigger when stored as arrays (though
> they still seem to take up more memory than they should)
>
> It's pretty easy to estimate the memory requirements for an image.  If the
> image is true-color (by this, I mean not color-mapped), you'll need
> 4-bytes-per-pixel for the original image, plus a cached scaled copy (the
> size of which depends on the output dpi), again with 4 bytes per pixel.  For
> color-mapped images, you'll have 4-byte floats for each pixel, 4-byte rgba
> for the color-mapped image, and again a cached scaled copy of that.  Not
> knowing the size of your input images, it's impossible to say if 40MB per
> image is way too big or not, but it's not unheard of by any means.
>
> Problems 1-3 seem problematic enough that they will get fixed eventually.
>
> ... but (4) is a design issue.  Assuming it's possible, it looks like there
> could be benefits to making an array-like wrapper around PIL image objects
> (perhaps similar in principle to a sparse matrix).  Given PIL.ImageMath,
> ImagePath, etc., it seems actually fairly doable.  Wouldn't something like
> this be of major benefit to people using SciPy for anything image-related?
>
> Are you suggesting decompressing the JPEG on-the-fly with each redraw?  I'm
> not certain that would be fast enough for interactive use.  It may be worth
> experimenting with, but it would require a lot of changes to how matplotlib
> works.  It's also very tricky to get right -- I'm not aware of any image
> processing applications that don't ultimately store a dense matrix of
> uncompressed image data in memory, except for something like  compressed
> OpenGL textures on a graphics card.  PIL certainly doesn't retain the
> compressed JPEG in memory.  So, I'm not sure the cost/benefit tradeoff is
> right here -- the problems it solves can be solved much more easily without
> sacrificing speed in other ways.  That is, if the image data is simply too
> large, it can be scaled before feeding it to imshow().  And generating
> multiple figures in batch is not a problem if the figure is explicitly
> closed.
>
> Hope this helps.  I would like to get to the bottom of any memory leaks, so
> if you can provide a standalone script that leaks, despite calling
> figure.close() in each iteration, please let me know.
>
> Cheers,
> Mike
>
> Leo
>
> On

Re: [Matplotlib-users] Images and memory management

2009-10-11 Thread Robert Kern
Leo Trottier wrote:
> Hi Michael,
> 
> I suppose I'm a bit confused --  I thought that jpeglib, part of which
> is implemented by PIL (??)

Other way around. PIL uses jpeglib to read JPEG files.

> could process compressed images without
> representing decompressing them to a dense raster-image matrix
> (http://en.wikipedia.org/wiki/Jpeglib).

However, PIL does not use make use of such capabilities. It just reads in the 
data into uncompressed memory just like it does with any other image format.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot color as a function of values?

2009-10-11 Thread Xavier Gnata
Hi,

Imagine you have something like:

from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
ax = subplot(111)
ax.plot(t, s)

That's fine but now I would like to plot the negative parts of the curve 
in red and the positive one in green.
Is there a nice pylab oriented way to do that? Some kind of "conditional 
formating"?

Xavier

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-10-11 Thread Eric Firing
John [H2O] wrote:
> 
> Jeff Whitaker wrote:
>>
>> John:  I don't have time to look at your code right now, but let me just 
>> make some general comments about plotting images on maps.  If you want 
>> to use imshow, the data your are plotting must coincide exactly with 
>> your map plot area.  So, for example if you want to plot a global 
>> lat/lon grid on a north polar stereographic projection, you have to 
>> interpolate to a rectangular grid in projection coordinates that fits in 
>> the map region.  However, in practice I find it's almost never worth 
>> doing this.  You can plot the data in the native coordinates on almost 
>> any map projection region using pcolormesh or contourf,  Just calculate 
>> the x,y values of the of the data grid, and pass those values along with 
>> the data to either one of those methods.  Is there any particular reason 
>> you want to use imshow, instead of pcolormesh or contourf?
>>
>> -Jeff
>>
>>
> 
> Jeff,
> 
> I started using pcolormesh, but ran into the problem that I really required
> a log scale color map for the plotting. As I recall, this could only be done
> with imshow - but perhaps that has changed? Regardless, I've done some

All the "mappables" like images, pcolor-type plots (including 
pcolormesh), scatter, and collections can be created with a colormap and 
a norm.  Using norm=LogNorm() gives you a log scale for color.  See 
http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_log.html?highlight=pcolor_log



> further testing. It seems I have the following problems with it:
> 
> 1) It is much more 'coarse' in the coloring, imshow offers a finer/smoother
> looking gradient. 

Imshow by default interpolates the colors; the pcolor* functions/methods 
do not.

Eric

> 
> 2) The bigger problem occurs when plotting in npstere, which I use quite
> often. Maybe I have to add a wrap around, but as it is, I get a 'seam' at
> the -180/180 meridian. 
> 
> 3) At the pole, there is a empty spot, creating a hole in my plots. This I
> can't work with... :s
> 
> Thanks again for your input.
> 
> -john 
> 
> 


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] readshapefile

2009-10-11 Thread Jeff Whitaker
Steve Westenbroek wrote:
> Hi Jeff,
>
> I apologize in advance for contacting you directly, however, I've been
> Googling and RTFM-ing to no avail!
>
> If you have time and/or inclination, I have two questions for you
> regarding the Basemap module under Matplotlib.
>
> 1) I've been struggling to use "readshapefile" to load a simple polyline
> shapefile. I'm currently running the Enthought Python Distribution
> v5.1.0 on Windows XP. I stumbled onto an archived email message from 
> you  describing how one does a "python setup.py install" from within 
> the Thuban source directory. I can verify that the pytest.py script 
> works following installation. However, I cannot get Python to 
> recognize "readshapefile" as a valid method. I'm sure there is a 
> simple solution to this, but it is just out of my reach. Any ideas?
>
Steve:  You have to create a basemap class instance, then call the 
readshape file method.  All the necessary dependencies are included, you 
don't have to install anything else.  Try running the fillstates.py 
demo, and if that works, everything is fine.
> 2) It does not appear that one can simply pass through the Proj4 
> string when invoking "Basemap"? Is this true?  I have some whacky 
> (i.e. project-specific) projection parameters that I'd love to simply 
> feed into "Basemap", but it doesn't appear to be a possibility. If I 
> am correct, do you have a sense for how difficult it would be to 
> modify Basemap to accept Proj4 strings?

It's impossible, because a) Basemap doesn't support all the possible 
proj4 projections, and b) not all the info Basemap needs can be 
specified in a proj4 string.

Have you seen the documentation at

http://matplotlib.sourceforge.net/basemap/doc/html/ ?

-Jeff
>
> Thanks in advance!  It seems that I am tantalizingly close to making 
> this work for my problem.
>
> Cheers,
>
>  - Steve
>


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot color as a function of values?

2009-10-11 Thread Eric Firing
Xavier Gnata wrote:
> Hi,
> 
> Imagine you have something like:
> 
> from pylab import *
> t = arange(0.0, 2.0, 0.01)
> s = sin(2*pi*t)
> ax = subplot(111)
> ax.plot(t, s)
> 
> That's fine but now I would like to plot the negative parts of the curve 
> in red and the positive one in green.
> Is there a nice pylab oriented way to do that? Some kind of "conditional 
> formating"?

Not built in, but you can do it easily with masked arrays.  See 
http://matplotlib.sourceforge.net/examples/pylab_examples/masked_demo.html

It is not exactly what you want, but close:

sneg = np.ma.masked_greater_equal(s, 0)
spos = np.ma.masked_less_equal(s, 0)
ax.plot(t, spos, 'g')
ax.plot(t, sneg, 'r')

What this does not do is ensure that there is no gap where the line 
crosses zero.  For that, you would need to ensure that your sampling of 
s(t) includes the zeros.

Eric


> 
> Xavier
> 
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap, transform_scalar question

2009-10-11 Thread Jeff Whitaker
John [H2O] wrote:
> Jeff Whitaker wrote:
>   
>> John:  I don't have time to look at your code right now, but let me just 
>> make some general comments about plotting images on maps.  If you want 
>> to use imshow, the data your are plotting must coincide exactly with 
>> your map plot area.  So, for example if you want to plot a global 
>> lat/lon grid on a north polar stereographic projection, you have to 
>> interpolate to a rectangular grid in projection coordinates that fits in 
>> the map region.  However, in practice I find it's almost never worth 
>> doing this.  You can plot the data in the native coordinates on almost 
>> any map projection region using pcolormesh or contourf,  Just calculate 
>> the x,y values of the of the data grid, and pass those values along with 
>> the data to either one of those methods.  Is there any particular reason 
>> you want to use imshow, instead of pcolormesh or contourf?
>>
>> -Jeff
>>
>>
>> 
>
> Jeff,
>
> I started using pcolormesh, but ran into the problem that I really required
> a log scale color map for the plotting. As I recall, this could only be done
> with imshow - but perhaps that has changed? 
John:

The color mapping is the same with imshow or pcolormesh.  See the recent 
thread on "logarithmic colormaps".
> Regardless, I've done some
> further testing. It seems I have the following problems with it:
>
> 1) It is much more 'coarse' in the coloring, imshow offers a finer/smoother
> looking gradient. 
>   
Only way around that with pcolormesh is to interpolate to a finer grid.  
Imshow will interpolate the colors, pcolormesh will not.
> 2) The bigger problem occurs when plotting in npstere, which I use quite
> often. Maybe I have to add a wrap around, but as it is, I get a 'seam' at
> the -180/180 meridian. 
>   
Just add a wraparound - that's easy with the addcyclic function.
> 3) At the pole, there is a empty spot, creating a hole in my plots. This I
> can't work with... :s
>   
That's because you don't have a grid point at the pole.  You could add 
one (by extrapolating the from the highest latitude).

-Jeff
> Thanks again for your input.
>
> -john 
>
>
>   


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] making horizontal axes labels in plots

2009-10-11 Thread per freem
hi all,

i am trying to make horizontal (as opposed to the default vertical)
rotated labels for axes in my subplots. i tried using the
'orientation' optional argument, as follows:

from numpy import *
from scipy import *
from mpl_toolkits.axes_grid.axislines import SubplotZero
import matplotlib.pyplot as plt
fig = plt.figure()
ax = SubplotZero(fig, 3, 1, 1)
ax1 = fig.add_subplot(ax)
ax.axis["xzero"].set_visible(True)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("hello", rotation='horizontal')
ax = SubplotZero(fig, 3, 1, 2)
ax2 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.4, 3.01], label="line b", c='b')
plt.ylabel("world")
ax = SubplotZero(fig, 3, 1, 3)
ax3 = fig.add_subplot(ax)
plt.plot([1,2,3], label="line a", c='r')
plt.plot([1.2, 2.01, 3.01], label="line b", c='b')
plt.figlegend([ax1.lines[0], ax1.lines[1]], ["line a", "line b"], 'upper right')

but it does not work. both the labels "hello" and "world" of the y
axes are displayed in their default vertical orientation. the argument
seems to have no effect. i am using matplotlib '0.99.0' on Mac OS X.
any ideas how to fix this?

thanks.

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot color as a function of values?

2009-10-11 Thread Xavier Gnata
Eric Firing wrote:
> Xavier Gnata wrote:
>> Hi,
>>
>> Imagine you have something like:
>>
>> from pylab import *
>> t = arange(0.0, 2.0, 0.01)
>> s = sin(2*pi*t)
>> ax = subplot(111)
>> ax.plot(t, s)
>>
>> That's fine but now I would like to plot the negative parts of the 
>> curve in red and the positive one in green.
>> Is there a nice pylab oriented way to do that? Some kind of 
>> "conditional formating"?
>
> Not built in, but you can do it easily with masked arrays.  See 
> http://matplotlib.sourceforge.net/examples/pylab_examples/masked_demo.html 
>
>
> It is not exactly what you want, but close:
>
> sneg = np.ma.masked_greater_equal(s, 0)
> spos = np.ma.masked_less_equal(s, 0)
> ax.plot(t, spos, 'g')
> ax.plot(t, sneg, 'r')
>
> What this does not do is ensure that there is no gap where the line 
> crosses zero.  For that, you would need to ensure that your sampling 
> of s(t) includes the zeros.
>
> Eric

It should do the trick because my sampling is very high.

Xavier

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users