Skip to content

Commit aa07d18

Browse files
committed
axes_grid1: fix colorbar not processing the ticks keyword properly
1 parent f6ebac9 commit aa07d18

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/mpl_toolkits/axes_grid1/axes_grid.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ class CbarAxesBase(object):
6666

6767
def colorbar(self, mappable, **kwargs):
6868
locator=kwargs.pop("locator", None)
69-
if locator is None:
70-
locator = ticker.MaxNLocator(5)
71-
self.locator = locator
72-
73-
kwargs["ticks"] = locator
7469

70+
if locator is None:
71+
if "ticks" not in kwargs:
72+
kwargs["ticks"] = ticker.MaxNLocator(5)
73+
if locator is not None:
74+
if "ticks" in kwargs:
75+
raise ValueError("Either *locator* or *ticks* need to be given, not both")
76+
else:
77+
kwargs["ticks"] = locator
7578

7679
self.hold(True)
7780
if self.orientation in ["top", "bottom"]:
@@ -90,6 +93,9 @@ def on_changed(m):
9093

9194
self.cbid = mappable.callbacksSM.connect('changed', on_changed)
9295
mappable.set_colorbar(cb, self)
96+
97+
self.locator = cb.cbar_axis.get_major_locator()
98+
9399
return cb
94100

95101
def _config_axes(self):

0 commit comments

Comments
 (0)