Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Jae-Joon Lee
On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing  wrote:
>
> Done in svn 8205.
>

Thanks!

>>
>> Or, how about we make axes an context manager.
>
> This would require dropping support for Python 2.4.

I don't think making the Axes a context manager means dropping python
2.4 support
(note that I'm not saying we use "with" statement in the mpl source).
Everything should work fine in python 2.4 (please correct me if I'm wrong).
It just gives a user a choice. If a user runs his/her script with
python 2.5 and higher, he/she has an option to use an axes as an
context manager. Of course, if he/she want his/her own code supported
in python 2.4, he/she should not use "with" statement.

Regards,

-JJ

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Ryan May
On Sun, Mar 21, 2010 at 12:35 PM, Jae-Joon Lee  wrote:
> On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing  wrote:
>>> Or, how about we make axes an context manager.
>>
>> This would require dropping support for Python 2.4.
>
> I don't think making the Axes a context manager means dropping python
> 2.4 support
> (note that I'm not saying we use "with" statement in the mpl source).
> Everything should work fine in python 2.4 (please correct me if I'm wrong).
> It just gives a user a choice. If a user runs his/her script with
> python 2.5 and higher, he/she has an option to use an axes as an
> context manager. Of course, if he/she want his/her own code supported
> in python 2.4, he/she should not use "with" statement.

I see what you're saying.  While the use of the language syntax is
restricted to 2.5 and above, we could add the needed methods to the
Axes object, which would just be ignored by python <2.5.  That's not a
bad idea.

I'm +1 on the idea.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Eric Firing
Ryan May wrote:
> On Sun, Mar 21, 2010 at 12:35 PM, Jae-Joon Lee  wrote:
>> On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing  wrote:
 Or, how about we make axes an context manager.
>>> This would require dropping support for Python 2.4.
>> I don't think making the Axes a context manager means dropping python
>> 2.4 support
>> (note that I'm not saying we use "with" statement in the mpl source).
>> Everything should work fine in python 2.4 (please correct me if I'm wrong).
>> It just gives a user a choice. If a user runs his/her script with
>> python 2.5 and higher, he/she has an option to use an axes as an
>> context manager. Of course, if he/she want his/her own code supported
>> in python 2.4, he/she should not use "with" statement.
> 
> I see what you're saying.  While the use of the language syntax is
> restricted to 2.5 and above, we could add the needed methods to the
> Axes object, which would just be ignored by python <2.5.  That's not a
> bad idea.
> 
> I'm +1 on the idea.


Is the added complexity, scrambling pylab into the OO layer, and need 
for explanation, really worth the gain?  As far as I can see, it merely 
adds one more way to do something--and not a particularly recommended 
way.  It is no more concise than using sca().  It may be slightly more 
readable because of the indentation, but that is the only advantage I see.

Eric

> 
> Ryan
> 


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Jae-Joon Lee
On Sun, Mar 21, 2010 at 2:30 PM, Eric Firing  wrote:
> Is the added complexity, scrambling pylab into the OO layer, and need for
> explanation, really worth the gain?  As far as I can see, it merely adds
one
> more way to do something--and not a particularly recommended way.  It is
no
> more concise than using sca().  It may be slightly more readable because
of
> the indentation, but that is the only advantage I see.
>

* complexity

   I guess the code below is a "minimal" implementation (it worked okay with
my limited tests).

   # context manager

   def __enter__(self):

   import matplotlib.pyplot as plt

   plt.sca(self)

   return self

   def __exit__(self, type, value, tb):

   pass


* readability

1) with "with" statement

fig, axarr = subplots(2,2)


> for ax1, ax2 in axarr:

with ax1:

plot([1,2,3])


> with ax2:

   plot([2,3,4])


2) with "sca"


> fig, axarr = subplots(2,2)


> for ax1, ax2 in axarr:

   sca(ax1)

   plot([1,2,3])


>sca(ax2)

   plot([2,3,4])



While I certainly prefer 1) over 2) as far as the readability is concerned,
I currently don't have a strong opinion whether the readability beats the
complexity in this case.

So, unless there are more of positive feedbacks from others, I'll consider
it dropped.

Regards,

-JJ
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Jae-Joon Lee
On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing  wrote:

> By the way, given that we now have "suplots" in the pyplot namespace,
>> can we have sca also?
>>
>
> Done in svn 8205.
>


Eric,

A minor question. I wonder whether an explicit for-loop inside pyplot.sca is
necessary?
Here is a slight variation w/o a for-loop (well, the for-loop is implicitly
done with the "in" operator I guess) that seems to work for me, but I may be
missing something.

managers = _pylab_helpers.Gcf.get_all_fig_managers()
if ax.figure.canvas.manager in managers and \
   ax in ax.figure.axes:
_pylab_helpers.Gcf.set_active(ax.figure.canvas.manager)
ax.figure.sca(ax)
return
raise ValueError("Axes instance argument was not found in a figure.")

Regards,

-JJ
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Eric Firing
Jae-Joon Lee wrote:
> 
> 
> On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing  > wrote:
> 
> By the way, given that we now have "suplots" in the pyplot
> namespace,
> can we have sca also?
> 
> 
> Done in svn 8205.
> 
> 
> 
> Eric,
> 
> A minor question. I wonder whether an explicit for-loop inside 
> pyplot.sca is necessary?
> Here is a slight variation w/o a for-loop (well, the for-loop is 
> implicitly done with the "in" operator I guess) that seems to work for 
> me, but I may be missing something.  
> 
> managers = _pylab_helpers.Gcf.get_all_fig_managers()
> if ax.figure.canvas.manager in managers and \
>ax in ax.figure.axes:
> _pylab_helpers.Gcf.set_active(ax.figure.canvas.manager)
> ax.figure.sca(ax)
> return
> raise ValueError("Axes instance argument was not found in a figure.")
> 
> Regards,
> 
> -JJ
> 

JJ,

I think your version would need an additional try/except or conditional, 
because a Figure doesn't necessarily have a canvas assigned to it, and a 
canvas doesn't necessarily have a manager.  Granted, the problem would 
arise only under odd circumstances involving a mixture of pyplot and OO 
styles--and maybe there is actually something that would prevent the 
problem from arising at all--but I would want to be sure the problem 
either was handled, or could not arise.  So, I think my version ends up 
being simpler, safer, and easier to understand--at least for me.

Eric


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Selecting all the way to the edge of a plot

2010-03-21 Thread Jae-Joon Lee
On Sun, Mar 14, 2010 at 3:43 PM, Anne Archibald
wrote:

> Often when I want to
> zoom in, I want to change only (say) the upper x and y limits.
>

I pushed a change into the svn that enables this, but in a different way
than you suggested.
The behavior I implemented is similar to the current behavior of the "pan"
mode, i.e., if you hold the "x" key pressed during pan/zoom, only the x-axis
is updated. Same for "y" key.

I hope this is good for your needs also.

Regards,

-JJ
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Jae-Joon Lee
On Sun, Mar 21, 2010 at 6:07 PM, Eric Firing  wrote:

> I think your version would need an additional try/except or conditional,
> because a Figure doesn't necessarily have a canvas assigned to it, and a
> canvas doesn't necessarily have a manager.  Granted, the problem would arise
> only under odd circumstances involving a mixture of pyplot and OO
> styles--and maybe there is actually something that would prevent the problem
> from arising at all--but I would want to be sure the problem either was
> handled, or could not arise.  So, I think my version ends up being simpler,
> safer, and easier to understand--at least for me.
>

I see. Thanks!

-JJ
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Selecting all the way to the edge of a plot

2010-03-21 Thread Anne Archibald
On 21 March 2010 18:10, Jae-Joon Lee  wrote:
>
>
> On Sun, Mar 14, 2010 at 3:43 PM, Anne Archibald 
> wrote:
>>
>> Often when I want to
>> zoom in, I want to change only (say) the upper x and y limits.
>
> I pushed a change into the svn that enables this, but in a different way
> than you suggested.
> The behavior I implemented is similar to the current behavior of the "pan"
> mode, i.e., if you hold the "x" key pressed during pan/zoom, only the x-axis
> is updated. Same for "y" key.
> I hope this is good for your needs also.

Well, it's an interesting feature, but it doesn't address the problem
I'm seeing.

What I'd like to be able to do is, say, to change only the upper x and
y limits, simply click where I want those limits to be and drag right
off the corner of the plot. This actually works, but when I do this
the drag rectangle freezes the moment my pointer leaves the axes, so
that it does not represent the area being zoomed to.

I've attached a screenshot illustrating the bug. Note where the
pointer is and where the "to be zoomed" rectangle is.

I use Linux, with the default backend, whatever that is.

Anne

> Regards,
> -JJ
>
<>--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?

2010-03-21 Thread Fernando Perez
On Sat, Mar 20, 2010 at 4:00 PM, Jae-Joon Lee  wrote:
> On Sat, Mar 20, 2010 at 5:05 AM, Fernando Perez  wrote:
>> I wonder if it's possible to put things like a draw_if_interactive()
>> call at the end of the OO methods... I realize that pyplot was the
>> only one meant to do that, but if we are to encourage using the OO api
>> more, then it's going to have to be as pleasant to use as pyplot...  I
>> don't know the codebase well enough to mess with this right now, so I
>> hope someone who's more versed in that part of the code can make a fix
>> for this whose  impact isn't too severe on the runtime of OO code.
>
> I'm not very inclined to this but I'll wait to hear what others think.
> I use oo api in the interactive mode but I still prefer to call draw()
> explicitly.
> Of course, we can make it optional.

Mmh, back to this one: I do think it would be something useful to have
somewhere, because typing draw() after *every* operation when working
interactively does get tiresome, it seems to me...  If we encourage
calling subplots() for new teaching, then we do want it to be as
pleasant as pyplot to use interactively, I think...

Is it technically expensive to put in?

Cheers,

f

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] two problems with zorder

2010-03-21 Thread Phillip M. Feldman
I have two zorder-related complaints:

(1) The default zorder is not reasonable. If I plot a bar chart and then 
overlay a scatter diagram, the scatter diagram symbols are behind the 
bars. If I reverse the order, i.e., I generate the scatter diagram 
first, the scatter diagram symbols are still behind the bars. This 
doesn't make sense. Something that gets plotted later should be on top 
of whatever was plotted earlier.

(2) One really has to poke around to find the documentation for zorder. 
It would be great if the documentation for something as important as 
this were easier to find.

Thanks!

Phillip

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel