Paul Ivanov, on 2011-01-22 18:28, wrote: > Ilya Shlyakhter, on 2011-01-22 19:06, wrote: > > Is it possible to create a "break" in the y-axis so that it has ticks > > for value 0-.2, then ticks for values .8-1.0, but devotes only a token > > amount of space to the area 0.2-0.8? > > I have a dataset with most datapoints in 0-.2 and a couple in .8-1.0, > > and none in .2-.8 . The default scaling wastes a lot of space and > > compresses the data in the 0-.2 range > > such that it is hard to distinguish. > > Hi Ilya, > > this... > > > p.s. I know I could use two y-axes with different scales; but this > > would require splitting the data into two different datasets as well, > > and would not allow connecting all points > > with one line. > > ... is the way I'd proceed, because it's clean, and requires the > least amount of work. Connecting your lines across such breaks > is misleading - since the magnitude of the slope of the > connecting line segment arbitrary relative to all other line > segments. You don't actually have to divide your data, you can > just replot *all* data on the secondary plot, and then set the x > and y lims to break up your views on the data. I'm attaching a > quick sketch of what that would look like. (Note how different > the outlier line segments would look if we connected them in the > same manner that all other points are connected). > > import numpy as np > import matplotlib.pylab as plt > pts = np.random.rand(30)*.2 > pts[[7,11]] += .8 > f,(ax,ax2) = plt.subplots(2,1,sharex=True) > > ax.plot(pts) > ax2.plot(pts) > ax.set_ylim(.78,1.) > ax2.set_ylim(0,.22) > > ax.xaxis.tick_top() > ax.spines['bottom'].set_visible(False) > ax.tick_params(labeltop='off') > ax2.xaxis.tick_bottom() > ax2.spines['top'].set_visible(False) > > If this is something you really want, though, you can achieve it > by making your own projection/scale: > http://matplotlib.sourceforge.net/devel/add_new_projection.html > > Yet another way would be to re-label the tick lines (e.g. make .6 > label be 1.0 and subtract that offset from your two outliers.
forgot the attachment, here it is. -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
<<attachment: snipped_ticks.png>>
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users