From: Jae-Joon L. <lee...@gm...> - 2010-08-17 00:14:16
|
Using the set_powerlimits method didn't help? As far as I know, the current implementation does not allow a custom scale factor. But if the scale factor is power of 10 (10, 100, 1000, ...), I believe using set_powerlimits method (as in my previous example, or some variation) is good enough. Let me know if it does not work or you have any other problem. Regards, -JJ On Tue, Aug 17, 2010 at 3:17 AM, Jeremy Conlin <jlc...@gm...> wrote: > On Sun, Aug 15, 2010 at 10:49 PM, Jae-Joon Lee <lee...@gm...> wrote: >> On Fri, Aug 13, 2010 at 3:34 AM, Jeremy Conlin <jlc...@gm...> wrote: >>> I have a problem with the scaling of the numbers on a colorbar. The >>> problem occurs when the numbers used as colorbar labels need to be >>> scaled (i.e. by 1E3). The colorbar correctly puts the scaling value >>> on the top of the colorbar, but instead of of multiplying by a scale >>> factor, addition is used instead. See the attached script and figure >>> for example. In the example, it looks like the color scale goes from >>> 0 to 2*5E3. At least, that's what I thought when I first looked at >>> it. Instead it means 5000 to 5002. >>> >>> Is there anyway I can scale the colorbar labels by *multiplying* them >>> by a scaling factor instead of *adding* a scaling factor? That seems >>> more intuitive to me and those I work with. >>> >> >> Given the value range of 5000-5002, I doubt how using the scaling >> factor improve your plot. >> >> To disable the use of offset (+5000), >> >> cb = fig.colorbar(pc) >> >> # do not use offset >> cb.formatter.set_useOffset(False) >> >> cb.update_ticks() >> >> If you do want to use scaling factor, >> >> # to use scaling factor >> cb.formatter.set_scientific(True) >> cb.formatter.set_powerlimits((0,0)) >> >> cb.update_ticks() >> >> This will only work with matplotlib v1.0. >> In older versions, try to replace "update_ticks" with >> "update_bruteforce" (but I'm not sure if this will work) >> >> IHTH, >> > > Thanks for your suggestions. I recognize that a range of 5000–5002 is > not much; it was used simply to illustrate my point. > > I was able to turn the scaling off with set_useOffset(False). Is > there anyway to scale by multiplying instead of adding? > > Thanks, > Jeremy > |