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

Skip to content

Commit ffaaabd

Browse files
committed
Turn minorticks on for Log Colorbar only on initialization or full reset
Fixes issue where colorbar lognorm minorticks are turned back on anytime ticks are updated
1 parent f92bd01 commit ffaaabd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ def _reset_locator_formatter_scale(self):
579579
# mid point is easier.
580580
self.ax.set_xscale('log')
581581
self.ax.set_yscale('log')
582+
583+
self.minorticks_on()
582584
else:
583585
self.ax.set_xscale('linear')
584586
self.ax.set_yscale('linear')
@@ -602,8 +604,6 @@ def update_ticks(self):
602604
_log.debug('locator: %r', locator)
603605
long_axis.set_major_locator(locator)
604606
long_axis.set_major_formatter(formatter)
605-
if type(self.norm) == colors.LogNorm:
606-
self.minorticks_on()
607607
else:
608608
_log.debug('Using fixed locator on colorbar')
609609
ticks, ticklabels, offset_string = self._ticker(locator, formatter)

lib/matplotlib/tests/test_colorbar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ def test_colorbar_minorticks_on_off():
325325
assert np.array_equal(cbar.ax.yaxis.get_minorticklocs(),
326326
default_minorticklocks)
327327

328+
# test issue #13339: minorticks for LogNorm should stay off
329+
cbar.minorticks_off()
330+
cbar.set_ticks([3, 5, 7, 9])
331+
assert np.array_equal(cbar.ax.yaxis.get_minorticklocs(),
332+
np.array([]))
333+
328334

329335
def test_colorbar_autoticks():
330336
# Test new autotick modes. Needs to be classic because

0 commit comments

Comments
 (0)