Jae-Joon Lee wrote: > On Wed, Jan 20, 2010 at 12:12 PM, Mario Mech <m...@meteo.uni-koeln.de> wrote: >> the smallest value (0.0) is labeled with "-0.0". I just want to get rid of >> the minus sign. >> > > This is because the actual value is "-9.00000000e-06" (this inherits > from the levels of contour). > While I think we're fixing a wrong problem (the contour routine need > to be fixed in my view), here is a workaround you may use.
Careful, that slight adjustment of the lower limit, when automatically generated, is there for a reason (though I don't recall offhand where it is arising and why). There may be a better way to do it--and we can try to figure it out and implement it--but my advice in general is: don't use automatically generated contour or contourf levels except for exploratory, interactive work, when slight imperfections are acceptable. Instead, figure out what levels you really want, and supply them explicitly as one of the arguments. Second and related advice: don't fiddle directly with tick labels except as a *last* resort. Instead, take care in selecting tick values, and if necessary, customize the Formatter. The fact that a default Formatter is writing -0.0 strikes me as a bug that should be fixed in the Formatter; but it would be good to have more opinions about this. Eric > > -JJ > > import numpy as np > from matplotlib import pyplot,mpl > > x = np.arange(10) > y = np.arange(25) > z = np.floor(10*np.random.random((25,10))) > > cntr = pyplot.contourf(x,y,z) > > cb = pyplot.colorbar(format=r"%2.1f") > > > ticklabel_seq = cb.ax.yaxis.major.formatter.seq > try: > indx = ticklabel_seq.index("-0.0") > ticklabel_seq[indx]="0.0" > except ValueError: > pass > > > pyplot.show() > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users