From: Francesco M. <fra...@go...> - 2011-02-04 16:01:44
|
Dear all again, I've tried to play with it again, but I couldn't find a solution for the problem. For clarity I report an example of what each of the subplots looks like: > import numpy as np > import matplotlib.pyplot as plt > mean = np.array([-0.9206394, -0.90127456, -0.91983625, -0.97765539, -1.02991184, -1.02267017, -0.97730167, -0.93715172, -0.94324653, -0.92884379]) > stddev = np.array([0.16351397, 0.15075966, 0.13413909, 0.15404823, 0.13559582, 0.13109754, 0.12128598, 0.11589682, 0.11921571, 0.10866761]) > > ax = plt.figure().add_axes([0.1,0.1,0.8,0.8]) > ax.errorbar(np.arange(10,20)/100., mean, yerr=stddev) > > ax.set_xlim([0.095, 0.195]) > lab = ax.get_ymajorticklabels() > > print lab > for i in lab: > print i > > plt.show() as output of this script I get > <a list of 7 Text yticklabel objects> > Text(0,0,'') > Text(0,0,'') > Text(0,0,'') > Text(0,0,'') > Text(0,0,'') > Text(0,0,'') > Text(0,0,'') In the plot instead I only have only 5 y tick labels, as visible from the attachment. In this case if I set the first and the last label invisible, nothing changes, and if I have other plots under this the plot becomes ugly/unreadable. I hope to have been clearer than in my previous mail. Any suggestion on how to fix or find a workaround in order to get the same number of tick labels as the ones actually plotted. Thank in advance Fra 2011/2/1 Francesco Montesano <fra...@go...>: > Dear all, > > I'm producing a single figure with subplots arrange in a single columns. > They all share the same x range but the y variable change from subplot to > subplot > > In order have a nicer figure I hide the first and the last y label of each > subplot in the following way >> >> ytl = subpl.get_ymajorticklabels() >> ytl[0].set_visible(False) >> ytl[-1].set_visible(False) > > It was well in most cases. But I've noticed that in some plot the first > and/or the last label remains. > In this cases, if I "print ytl", it writes "<a list of n Text yticklabel > objects>", where "n" is larger by 1 or 2 than the number of labels shown > before I make them invisible. > So I end up having some label (nearly) exactly on the upper and/or bottom > range of the plot. > > Is there a way to force the axis to return exactly the number of labels > shown in the plot? > > Thanks in advance, > > Francesco > > > -- personals: mon...@ya..., mon...@ho... (messenger), fra...@go.... work: mon...@mp... http://picasaweb.google.it/franz.bergesund |