Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52e802b

Browse files
committed
Also allow minorticks_on for LogNorm
Also allow minorticks_on for LogNorm
1 parent 97209bd commit 52e802b

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

lib/matplotlib/colorbar.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,7 @@ def update_ticks(self):
538538
long_axis.set_major_locator(locator)
539539
long_axis.set_major_formatter(formatter)
540540
if type(self.norm) == colors.LogNorm:
541-
long_axis.set_minor_locator(_ColorbarLogLocator(self,
542-
base=10., subs='auto'))
543-
long_axis.set_minor_formatter(
544-
ticker.LogFormatterSciNotation()
545-
)
541+
self.minorticks_on()
546542
else:
547543
_log.debug('Using fixed locator on colorbar')
548544
ticks, ticklabels, offset_string = self._ticker(locator, formatter)
@@ -602,6 +598,30 @@ def set_ticklabels(self, ticklabels, update_ticks=True):
602598
cbook._warn_external("set_ticks() must have been called.")
603599
self.stale = True
604600

601+
def minorticks_on(self):
602+
"""
603+
Turns on the minor ticks on the colorbar without extruding
604+
into the "extend regions".
605+
"""
606+
ax = self.ax
607+
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
608+
609+
if long_axis.get_scale() == 'log':
610+
long_axis.set_minor_locator(_ColorbarLogLocator(self,
611+
base=10., subs='auto'))
612+
long_axis.set_minor_formatter(ticker.LogFormatterSciNotation())
613+
else:
614+
long_axis.set_minor_locator(_ColorbarAutoMinorLocator(self))
615+
616+
def minorticks_off(self):
617+
"""
618+
Turns off the minor ticks on the colorbar.
619+
"""
620+
ax = self.ax
621+
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
622+
623+
long_axis.set_minor_locator(ticker.NullLocator())
624+
605625
def _config_axes(self, X, Y):
606626
'''
607627
Make an axes patch and outline.
@@ -1209,29 +1229,6 @@ def remove(self):
12091229
# use_gridspec was True
12101230
ax.set_subplotspec(subplotspec)
12111231

1212-
def minorticks_on(self):
1213-
"""
1214-
Turns on the minor ticks on the colorbar without extruding
1215-
into the "extend regions".
1216-
"""
1217-
ax = self.ax
1218-
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
1219-
1220-
if long_axis.get_scale() == 'log':
1221-
cbook._warn_external('minorticks_on() has no effect on a '
1222-
'logarithmic colorbar axis')
1223-
else:
1224-
long_axis.set_minor_locator(_ColorbarAutoMinorLocator(self))
1225-
1226-
def minorticks_off(self):
1227-
"""
1228-
Turns off the minor ticks on the colorbar.
1229-
"""
1230-
ax = self.ax
1231-
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
1232-
1233-
long_axis.set_minor_locator(ticker.NullLocator())
1234-
12351232

12361233
@docstring.Substitution(make_axes_kw_doc)
12371234
def make_axes(parents, location=None, orientation=None, fraction=0.15,

0 commit comments

Comments
 (0)