Re: [matplotlib-devel] patch: step function plotting

2007-08-15 Thread Manuel Metz

Hi,
okay, I have added a keyword 'where' as suggested. I also now changed 
the way the incoming data is converted. I took this from the axes.pie() 
function. I don't know much about the unit types yet :-(


Concerning masked arrays: Do I have to consider something special there?

Manuel

Ted Drain wrote:

At 10:36 AM 8/14/2007, Eric Firing wrote:

Ted Drain wrote:

Manuel,
We do plots like this all the time.  One thing we've found that's 
nice to have is a keyword that controls when the increase in y 
happens.  We use a step style keyword that can be 'pre' (go up then 
right), 'post' (go right then up), and 'mid' (right 0.5, up, right 0.5).

Good idea.
Regarding your patch, you might want to check other areas in MPL for 
data processing examples.  I could be wrong but I'm not sure you can 
assume that incoming data is a float.  Some of the unit conversion 
examples or the line collection code might have better examples.


Incoming data can be any numeric type, but it ends up getting 
converted to the default float type (not float32) internally.


Whenever possible, it is good to support masked array input.


Agreed - but the way the patch was written, I don't think it will 
support anything but float (especially not the unit types).



Eric

Ted
At 07:59 AM 8/14/2007, Manuel Metz wrote:

Hi,

I have created a patch against latest svn that adds a function step 
to the axes class to plot step-functions ;-) It's really simple but 
nice ... Any interest in adding this?


Manuel




Index: axes.py
===
--- axes.py (revision 3709)
+++ axes.py (working copy)
@@ -4995,6 +4995,18 @@
  steps=[1, 2, 5, 10],
  integer=True))
 return im
+
+def step(self, x, y, *args, **kwargs):
+x2 = npy.zeros((2*len(x)), npy.float32)
+y2 = npy.zeros((2*len(x)), npy.float32)
+
+x2[0::2] = x
+x2[1::2] = x
+
+y2[1::2] = y
+y2[2::2] = y[:-1]
+
+self.plot(x2, y2, *args, **kwargs)

 class SubplotBase:
 """

- 


This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


- 


This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/


___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel





-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/




___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Index: axes.py
===
--- axes.py	(revision 3709)
+++ axes.py	(working copy)
@@ -4995,6 +4995,45 @@
  steps=[1, 2, 5, 10],
  integer=True))
 return im
+
+def step(self, x, y, *args, **kwargs):
+
+where = kwargs.pop('where', 'pre')
+
+if not iterable(x): x = npy.asarray([x]).astype(npy.float32)
+else: x = npy.asarray(x).astype(npy.float32)
+
+if not iterable(y): x = npy.asarray([y]).astype(npy.float32)
+else: y = npy.asarray(y).astype(npy.float32)
+
+x2 = npy.zeros((2*len(x)), npy.float32)
+y2 = npy.zeros((2*len(y)), npy.float32)
+
+if where=='pre':
+x2[0::2] = x
+x2[1::2] = x
+
+y2[0::2] = y
+y2[1:-1:2] = y[1:]
+y2[-1] = y[-1]
+elif where=='post':
+x2[0] = x[0]
+ 

Re: [matplotlib-devel] Cannot set nonpositive limits with log transform

2007-08-15 Thread Darren Dale
On Tuesday 14 August 2007 07:35:43 pm Darren Dale wrote:
> I'm developing an application for work and need to plot some spectra on a
> logscale. I can recreate my problem with embedding_in_qt4, by replacing
> MyDynamicMplCanvas.compute_initial_figure with this:
>
> def compute_initial_figure(self):
>  self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r')
>  self.axes.set_yscale('log')
>
> [...]
> File
> "/usr/lib64/python2.5/site-packages/matplotlib-0.90.1_r3709-py2.5-linux-x86
>_64.egg/matplotlib/axes.py", line 1664, in set_ylim
> raise ValueError('Cannot set nonpositive limits with log transform')
> ValueError: Cannot set nonpositive limits with log transform
>
> I get that error even if I modify the update figure function so there is no
> possibility of zeros occuring in the data

I have tracked this back through axes.cla(), which is called when axes._hold 
is False, to axis.cla(). axis.cla() resets the locators, but the transforms 
are still set to mtrans.LOG10. Since plot is called by loglog, and semilog*, 
it shouldn't be using any methods that modify locators. If cla() resets the 
transforms, then the behavior of plot will be different, preserving log 
transforms when hold is True, but changing to linear transforms when hold is 
False.

I wonder if cla() is trying to do too much. Maybe the initial setting of 
locators should be moved out of cla(), which is called by Axes.__init__, and 
into Axis.__init__. Then calls to cla() will preserve the scaling, and the 
behavior of plot() will be consistent, regardless of the whether hold is 
enabled or not. 

Darren

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Cannot set nonpositive limits with log transform

2007-08-15 Thread Paul Kienzle
On Wed, Aug 15, 2007 at 09:57:21AM -0400, Darren Dale wrote:
> On Tuesday 14 August 2007 07:35:43 pm Darren Dale wrote:
> > I'm developing an application for work and need to plot some spectra on a
> > logscale. I can recreate my problem with embedding_in_qt4, by replacing
> > MyDynamicMplCanvas.compute_initial_figure with this:
> >
> > def compute_initial_figure(self):
> >  self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r')
> >  self.axes.set_yscale('log')
> >
> > [...]
> > File
> > "/usr/lib64/python2.5/site-packages/matplotlib-0.90.1_r3709-py2.5-linux-x86
> >_64.egg/matplotlib/axes.py", line 1664, in set_ylim
> > raise ValueError('Cannot set nonpositive limits with log transform')
> > ValueError: Cannot set nonpositive limits with log transform
> >
> > I get that error even if I modify the update figure function so there is no
> > possibility of zeros occuring in the data
> 
> I have tracked this back through axes.cla(), which is called when axes._hold 
> is False, to axis.cla(). axis.cla() resets the locators, but the transforms 
> are still set to mtrans.LOG10. Since plot is called by loglog, and semilog*, 
> it shouldn't be using any methods that modify locators. If cla() resets the 
> transforms, then the behavior of plot will be different, preserving log 
> transforms when hold is True, but changing to linear transforms when hold is 
> False.
> 
> I wonder if cla() is trying to do too much. Maybe the initial setting of 
> locators should be moved out of cla(), which is called by Axes.__init__, and 
> into Axis.__init__. Then calls to cla() will preserve the scaling, and the 
> behavior of plot() will be consistent, regardless of the whether hold is 
> enabled or not. 

The other option is to do something sensible when axes limits are
negative on the log scale.  We switch back and forth between linear and log
while zooming/panning.  Since it is difficult to keep the limits positive 
when using the linear scale we would love to have the plot handle bad
limits.  I don't have a patch yet, but I don't mind if you beat me to it 8-)

Ultimately we would like negative data to be represented using
an inverted logarithmic scale, but this is a more difficult project.
For now we are masking out any data <= 0.

  - Paul

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Cannot set nonpositive limits with log transform

2007-08-15 Thread Darren Dale
On Wednesday 15 August 2007 03:18:25 pm you wrote:
> On Wed, Aug 15, 2007 at 09:57:21AM -0400, Darren Dale wrote:
> > On Tuesday 14 August 2007 07:35:43 pm Darren Dale wrote:
> > > I'm developing an application for work and need to plot some spectra on
> > > a logscale. I can recreate my problem with embedding_in_qt4, by
> > > replacing MyDynamicMplCanvas.compute_initial_figure with this:
> > >
> > > def compute_initial_figure(self):
> > >  self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r')
> > >  self.axes.set_yscale('log')
> > >
> > > [...]
> > > File
> > > "/usr/lib64/python2.5/site-packages/matplotlib-0.90.1_r3709-py2.5-linux
> > >-x86 _64.egg/matplotlib/axes.py", line 1664, in set_ylim
> > > raise ValueError('Cannot set nonpositive limits with log
> > > transform') ValueError: Cannot set nonpositive limits with log
> > > transform
> > >
> > > I get that error even if I modify the update figure function so there
> > > is no possibility of zeros occuring in the data
> >
> > I have tracked this back through axes.cla(), which is called when
> > axes._hold is False, to axis.cla(). axis.cla() resets the locators, but
> > the transforms are still set to mtrans.LOG10. Since plot is called by
> > loglog, and semilog*, it shouldn't be using any methods that modify
> > locators. If cla() resets the transforms, then the behavior of plot will
> > be different, preserving log transforms when hold is True, but changing
> > to linear transforms when hold is False.
> >
> > I wonder if cla() is trying to do too much. Maybe the initial setting of
> > locators should be moved out of cla(), which is called by Axes.__init__,
> > and into Axis.__init__. Then calls to cla() will preserve the scaling,
> > and the behavior of plot() will be consistent, regardless of the whether
> > hold is enabled or not.
>
> The other option is to do something sensible when axes limits are
> negative on the log scale. 

Thats a seperate, but important issue. In the case I described, the state of 
the plot becomes a mash of log transforms and linear locators.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] imshow: set_extent

2007-08-15 Thread Darren Dale
I'm doing something along the lines of:

create an initial image with imshow
add a colorbar
update the image using the image's set_data method

Occassionally, the extents of the image will change. How do I handle that? The 
only place I can find to set the extents is in the call to imshow. The 
resulting image has a get_extents, but not a setter. I can't make repeated 
calls to imshow, because the new image isnt coupled to the colorbar. I can't 
figure out how to couple the colorbar to the new image, and I dont know how 
to get rid of the old colorbar to clear space for a new one.

Can someone offer some advice?

Also, does aspect='equal' work with the object oriented interface?

Thanks,
Darren


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] imshow: set_extent

2007-08-15 Thread Darren Dale
On Wednesday 15 August 2007 04:28:19 pm Darren Dale wrote:
> Also, does aspect='equal' work with the object oriented interface?

short answer: yes, if you expect it to do what its supposed to do.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel