First of all, thanks, klukas for the useful piece of code.

Jae-Joon Lee wrote:
> On Mon, Mar 29, 2010 at 12:30 PM, Jeff Klukas <klu...@wisc.edu> wrote:
>> # Create BrokenAxes with bottom from 0 to 5 and top from 30 to 35
>> ax = plt.broken_axes(ybounds=[0.,5.,30.,35.])
>> # Plot a line onto BOTH subaxes
>> ax.plot(range(35),range(35))
>>
>> The call to plot would get routed through __getattribute__, which
>> would then call plot for each of the subaxes.  This would be much more
>> intuitive than my existing breaky solution, where you have to loop
>> over all subaxes and plot on each individually.
>>
> 
> How do you want to handle
> 
> l1, = ax.plot(range(35), range(35))
> l1.set_color("r")
> 
> then?
> 

Well, I guess BrokenAxes.plot should return a list of lines instead of a
line in ll.
i.e. something like "[[x.lines[-1] for x in ax.subaxes]]"
would replace "[ax.lines[-1]]" as the return value.
Better yet, instead of a list we should have a "vector-type" proxy
container that should transfer method calls to the contained items.

> I think keeping two (or more) separate artists for each axes while an
> user think there is only one artist (because only one axes is exposed
> to the user) is not a good idea.

Ideally this should really be one artist.
However from JDH's response I understand this would be harder to
implement (using custom transforms or something). Maybe emulating one
using the current implementation (as I suggested above) is good enough.

Meanwhile, this redundant looping for each plot call is annoying, so I
can offer the following compromise: store the subaxes in the parent
(broken)Axes (add "self._subaxes = subaxes" before returning from breakx
and breaky), then add a new plot_subs method:

def plot_subs(self,*args,**keys):
    for sub in self._subaxes:
        res = sub.plot(*args,**keys)
    return res

This is a simplified version, returning just the lines of the last
subaxes, but at least this way you can avoid the looping.


 Regards,
     Amit A.


------------------------------------------------------------------------------
Download Intel&#174; 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
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to