John and others developers,
I think the current colorbar implementation has some (minor) issue
related with how ticks are treated.
Here is a quick example,
cb = colorbar()
This gives you a nice colorbar, However, an issue arises when you want
to change the ticks.
cax = cb.ax
cax.set_yticks([0, 40, 80])
And the colorbar got messed up.
Changing ticks and ticklabels after the colobar is created is quite tricky.
And, the easiest solution is to set those when creating the colorbar.
As far as I can see, the real confusion comes fromthe fact that, in
the current colorbar implementation, the data coordinate of the
colorbar axes has nothing to do with the actual color scale.
In the above example, while the color scale ranges from 0 to 99, the
data coordinate (ylim) is still from 0 to 1.
A few months back, I worked on a revised implementation of the
colorbar, and that version of colorbar is currently included in the
axes_grid toolkit. It is backward-compatible, but it uses
"axes_locator" feature that I'm a bit reluctant to push into the
So, here is a few possible resolutions I consider.
1) leave it as is. but issue a warning when a users calls "set_yticks"
(or its relatives) on the colobar axes.
2) use the reimplemented version of the colorbar, but drop the
axes_locator part. The colorbar will be fully functional except the
"extend" feature (triangles at the ends of the colorbar. see
3) use the reimplemented version of the colorbar.
4) someone else comes up with a better implementation.
I don't think there is an immediate need for any changes as I see it
as a minor issue.
I'm just posting this as there has been a few recent questions
regarding the colorbar behavior in the user list.
Any suggestion and/or comments?