You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
extra minor-ticks on the colorbar when used with the extend option #11510
changed the title [-]minor-ticks on the colorbar when used with the extend option[/-][+]extra minor-ticks on the colorbar when used with the extend option[/+]on Jun 26, 2018
I tried digging around in matplotlib/colorbar.py and found the following...
class_ColorbarAutoLocator(ticker.MaxNLocator):
""" AutoLocator for Colorbar This locator is just a `.MaxNLocator` except the min and max are clipped by the norm's min and max (i.e. vmin/vmax from the image/pcolor/contour object). This is necessary so ticks don't extrude into the "extend regions". """
This seems to suggest that the major ticks are calculated taking into account the extend regions.
Thanks for the report. Downgraded to 3.1 because this is a pretty old problem, usually obviated by not using minor ticks for colorbars.
What should happen is that colorbars get special treatment in choosing ticks. They got really special treatment before and that causes other problems.
I'll see what I can figure out, but it may take a bit. Of course if anyone else has a clever solution that would be great. The fundamental problem is that the colorbar extend triangles are drawn inside the colorbar axes, so the ticks try to extend off there. I suspect a solution where they draw outside the axes and aren't clipped to the axes is the best way to fix this.
For the minor tick problem, thats a bit harder because how you are calling it, the method has no way to know you are trying to set the tick locator for a colorbar axes. I'd suggest we add a new method to the colorbar object (not its axes) that turns the minor ticks on for the axes, i.e. cb.minorticks_on/off().
Activity
[-]minor-ticks on the colorbar when used with the extend option[/-][+]extra minor-ticks on the colorbar when used with the extend option[/+]pharshalp commentedon Jun 28, 2018
I tried digging around in matplotlib/colorbar.py and found the following...
This seems to suggest that the major ticks are calculated taking into account the extend regions.
TarasKuzyo commentedon Jul 2, 2018
If you add
vmax=5toim = ax.pcolormesh(x), you'll get-3extruded into the "extend regions".jklymak commentedon Jul 2, 2018
Thanks for the report. Downgraded to 3.1 because this is a pretty old problem, usually obviated by not using minor ticks for colorbars.
What should happen is that colorbars get special treatment in choosing ticks. They got really special treatment before and that causes other problems.
I'll see what I can figure out, but it may take a bit. Of course if anyone else has a clever solution that would be great. The fundamental problem is that the colorbar extend triangles are drawn inside the colorbar axes, so the ticks try to extend off there. I suspect a solution where they draw outside the axes and aren't clipped to the axes is the best way to fix this.
pharshalp commentedon Jul 2, 2018
@jklymak Thanks.

@TarasKuzyo the problem with the major ticks seems to go away when you specify both vmin and vmax (e.g. vmin=-3, vmax=5)
jklymak commentedon Jul 3, 2018
See #11556 for the major tick problem
For the minor tick problem, thats a bit harder because how you are calling it, the method has no way to know you are trying to set the tick locator for a colorbar axes. I'd suggest we add a new method to the colorbar object (not its axes) that turns the minor ticks on for the axes, i.e.
cb.minorticks_on/off().pharshalp commentedon Jul 3, 2018
@jklymak Thanks for your quick response and PR.
Taking a clue from you PR, can something like the following be used for cb.minorticks_on/off()?
jklymak commentedon Jul 3, 2018
I think that might work (plus doc string, plus API add etc... ;-) but you may also have to make a new _ColorbarAutoMinorLocator. I'm not sure.
Of course it'll still have an error until #11556 goes in, but could be done in parallel. If you wanted to make a PR, I'm happy to help and review.
pharshalp commentedon Jul 3, 2018
Sure, I will give it a try in a day or two. Would certainly appreciate your help.