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 >
brokenaxes.diff
Description: Binary data
------------------------------------------------------------------------------ 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