I haven't heard a response back about the proposal I posted for broken axes. Hopefully that just means people are busy :). If there are concerns about the method or interface, I'm certainly open to hearing them.
In the meantime, I've been thinking about the interface, and I think the more correct and more ambitious thing to do would be to create a new BrokenAxes class that inherits from Axes. The class could redefine __getattribute__ to pass most function calls straight to the subaxes. So in the end a session could look like the following: # 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. The more ambitious thing to do would be to also define a BrokenAxis class that inherits from Axis and would redefine get_ticklabel_extents to look as each subaxis and push the axis label far enough out to clear the ticklabels on all subaxes. Does that new interface sound like a good idea? Are there any show-stopping problems that seem apparent. If it sounds like something worth trying, I could take a stab at writing an implementation. Cheers, Jeff || Jeff Klukas, Research Assistant, Physics || University of Wisconsin -- Madison || jeff.klu...@gmail | jeffyklu...@aim | jeffklu...@skype || http://www.hep.wisc.edu/~jklukas/ On Thu, Mar 18, 2010 at 1:38 PM, Jeff Klukas <klu...@wisc.edu> wrote: > I have implemented breakx and breaky methods for the Axes class and > attached the diff for axes.py to this message. > > You can test out the function with the following examples: > ------------------ > import numpy as np > import matplotlib as mpl > import matplotlib.pyplot as plt > > # Broken y > fig = plt.figure() > main_axes = plt.axes() > plt.title('Broken x-axis example') > plt.xlabel('x-axis label') > subaxes = main_axes.breaky([0., 1.9, 5.1, 6.9, 9.1, 12]) > for axes in subaxes: > axes.plot(np.linspace(0,12,13),np.linspace(0,12,13)) > plt.ylabel('y-axis label') > plt.show() > > ------------------ > import numpy as np > import matplotlib as mpl > import matplotlib.pyplot as plt > # Broken x > fig = plt.figure() > main_axes = plt.axes() > plt.title('Broken x-axis example') > plt.ylabel('y-axis label') > subaxes = main_axes.breakx([0., 1.9, 5.1, 6.9, 9.1, 12]) > for axes in subaxes: > axes.plot(np.linspace(0,12,13),np.linspace(0,12,13)) > plt.xlabel('x-axis label') > plt.show() > --------------------- > > I've included in the docstrings some of the TODO items, but this is > pretty stable in its current form. > > Cheers, > Jeff > > || Jeff Klukas, Research Assistant, Physics > || University of Wisconsin -- Madison > || jeff.klu...@gmail | jeffyklu...@aim | jeffklu...@skype > || http://www.hep.wisc.edu/~jklukas/ > > > On Tue, Mar 16, 2010 at 1:08 PM, Jeff Klukas <klu...@wisc.edu> wrote: >>> What would be great is if you could refactor the basic functionality >>> into a matplotlib.Axes.breaky method (and possibly breakx but most >>> people request a broken y axis), which would resize the "self" axes >>> and return the broken compliment which could be plotted onto. Then >>> you could provide a thin pyplot wrapper much like pyplot.twinx, so >>> that pyplot as well as API users could benefit. >> >> I can try to do this. I think I would prefer, however, not to resize >> the "self" axes and continue with my current approach of creating two >> new axes within the original axes. On the user end, I think it makes >> more sense to set the title and ylabel of the main axes, rather than >> setting them for the individual upper and lower axes. More on that >> below. >> >>>> The only real problems here is that you need to >>>> explicitly plot things on both the upper and lower axes, and then I haven't >>>> figured out how to push out the y-axis label of the main axes object so it >>>> doesn't overlap with the tick labels of the upper and lower axes. So, I >>>> instead moved the y-labels of the upper and lower axes so that they appear >>>> at the center of the axis, but this is problematic. Any thoughts on how to >>>> do that part better? >>> >>> klukas, I'm afraid I don't understand your issue... Can you explain using >>> it differently? >> >> In my approach, you end up with a main axes object that is invisible, >> and then two visible axes objects (upper and lower) within the main >> axes. I would ideally like to have the y label display in the middle >> of the main y-axis, independent of where the break lies. If I place a >> y label on the main axes (which has ticks or tick labels), though, it >> appears right up against the axis line. I'd like it to be placed >> further to the left, clear of the tick labels that appear on the upper >> and lower axes. So, I'd like to be able to access whatever algorithm >> is used to choose the offset of the axis label, and explicitly set the >> offset of the ylabel for the main axes so that it clears the tick >> labels. >> >> // Jeff >> > ------------------------------------------------------------------------------ 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 Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel