colorbar backwards compatibility

I made a few modifications to the new colorbar, so part of my previous message no longer applies. If the new colorbar finds kwargs from colorbar_classic, it issues a warning and then proceeds to call colorbar_classic. This should keep most old code working as before.

Eric

Eric Firing wrote:

I made a few modifications to the new colorbar, so part of my previous message no longer applies. If the new colorbar finds kwargs from colorbar_classic, it issues a warning and then proceeds to call colorbar_classic. This should keep most old code working as before.

Eric

Eric: Thanks for all your hard work! Looks like it should make colorbar much more flexible (and useful).

Playing around with it a bit with I found that using a format string in the format keyword causes an exception:

Traceback (most recent call last):
  File "colorbar_test.py", line 10, in ?
    colorbar(format='%5.2f')
  File "/Users/jsw/lib/python/matplotlib/pylab.py", line 341, in colorbar
    ret = gcf().colorbar(mappable, cax = cax, **kw)
  File "/Users/jsw/lib/python/matplotlib/figure.py", line 676, in colorbar
    cb = cbar.Colorbar(cax, mappable, **kw)
  File "/Users/jsw/lib/python/matplotlib/colorbar.py", line 419, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "/Users/jsw/lib/python/matplotlib/colorbar.py", line 125, in __init__
    self.formatter = ticker.FormatStringFormatter(format)
AttributeError: 'module' object has no attribute 'FormatStringFormatter

Changing 'FormatStringFormatter' to 'FormatStrFormatter' in colorbar.py seems to fix it.

Also, the docs suggest that the ticks keyword can be a list, but if I use for example

colorbar(ticks=[-1.0,0,1.0])

I don't get what I expect. In fact, it seems to use the default tick locations no matter what assign to ticks (a list or a ticker object, such as MultipleLocator(4)). Am I mis-interpreting the docstrings?

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Jeff,

Playing around with it a bit with I found that using a format string in the format keyword causes an exception:

...

Changing 'FormatStringFormatter' to 'FormatStrFormatter' in colorbar.py seems to fix it.

Fixed, thanks. I thought I had tested that, but...

Also, the docs suggest that the ticks keyword can be a list, but if I use for example

colorbar(ticks=[-1.0,0,1.0])

I don't get what I expect. In fact, it seems to use the default tick locations no matter what assign to ticks (a list or a ticker object, such as MultipleLocator(4)). Am I mis-interpreting the docstrings?

It was working as you expected for images but not for contours. Now that is fixed also.

Eric

Eric Firing wrote:

Jeff,

Playing around with it a bit with I found that using a format string in the format keyword causes an exception:

...

Changing 'FormatStringFormatter' to 'FormatStrFormatter' in colorbar.py seems to fix it.

Fixed, thanks. I thought I had tested that, but...

Also, the docs suggest that the ticks keyword can be a list, but if I use for example

colorbar(ticks=[-1.0,0,1.0])

I don't get what I expect. In fact, it seems to use the default tick locations no matter what assign to ticks (a list or a ticker object, such as MultipleLocator(4)). Am I mis-interpreting the docstrings?

It was working as you expected for images but not for contours. Now that is fixed also.

Eric

Excellent, thanks Eric!

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...236...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg