|
21 | 21 | from matplotlib import _api, _docstring
|
22 | 22 | from matplotlib.ticker import (
|
23 | 23 | NullFormatter, ScalarFormatter, LogFormatterSciNotation, LogitFormatter,
|
24 |
| - LogLocator, AutoLocator, SymmetricalLogLocator, AsinhLocator, LogitLocator) |
| 24 | + NullLocator, AutoLocator, AutoMinorLocator, LogLocator, |
| 25 | + SymmetricalLogLocator, AsinhLocator, LogitLocator) |
25 | 26 | from matplotlib.transforms import Transform, IdentityTransform
|
26 | 27 |
|
27 | 28 |
|
@@ -107,9 +108,9 @@ def set_default_locators_and_formatters(self, axis):
|
107 | 108 | # update the minor locator for x and y axis based on rcParams
|
108 | 109 | if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or
|
109 | 110 | axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
|
110 |
| - axis.minorticks_on() |
| 111 | + axis.set_minor_locator(AutoMinorLocator()) |
111 | 112 | else:
|
112 |
| - axis.minorticks_off() |
| 113 | + axis.set_minor_locator(NullLocator()) |
113 | 114 |
|
114 | 115 | def get_transform(self):
|
115 | 116 | """
|
@@ -192,9 +193,9 @@ def set_default_locators_and_formatters(self, axis):
|
192 | 193 | # update the minor locator for x and y axis based on rcParams
|
193 | 194 | if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or
|
194 | 195 | axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
|
195 |
| - axis.minorticks_on() |
| 196 | + axis.set_minor_locator(AutoMinorLocator()) |
196 | 197 | else:
|
197 |
| - axis.minorticks_off() |
| 198 | + axis.set_minor_locator(NullLocator()) |
198 | 199 |
|
199 | 200 |
|
200 | 201 | class LogTransform(Transform):
|
@@ -286,10 +287,14 @@ def set_default_locators_and_formatters(self, axis):
|
286 | 287 | # docstring inherited
|
287 | 288 | axis.set_major_locator(LogLocator(self.base))
|
288 | 289 | axis.set_major_formatter(LogFormatterSciNotation(self.base))
|
289 |
| - axis.set_minor_locator(LogLocator(self.base, self.subs)) |
290 | 290 | axis.set_minor_formatter(
|
291 | 291 | LogFormatterSciNotation(self.base,
|
292 | 292 | labelOnlyBase=(self.subs is not None)))
|
| 293 | + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or |
| 294 | + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): |
| 295 | + axis.set_minor_locator(LogLocator(self.base, self.subs)) |
| 296 | + else: |
| 297 | + axis.set_minor_locator(NullLocator()) |
293 | 298 |
|
294 | 299 | def get_transform(self):
|
295 | 300 | """Return the `.LogTransform` associated with this scale."""
|
@@ -447,9 +452,13 @@ def set_default_locators_and_formatters(self, axis):
|
447 | 452 | # docstring inherited
|
448 | 453 | axis.set_major_locator(SymmetricalLogLocator(self.get_transform()))
|
449 | 454 | axis.set_major_formatter(LogFormatterSciNotation(self.base))
|
450 |
| - axis.set_minor_locator(SymmetricalLogLocator(self.get_transform(), |
451 |
| - self.subs)) |
452 | 455 | axis.set_minor_formatter(NullFormatter())
|
| 456 | + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or |
| 457 | + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): |
| 458 | + axis.set_minor_locator(SymmetricalLogLocator(self.get_transform(), |
| 459 | + self.subs)) |
| 460 | + else: |
| 461 | + axis.set_minor_locator(NullLocator()) |
453 | 462 |
|
454 | 463 | def get_transform(self):
|
455 | 464 | """Return the `.SymmetricalLogTransform` associated with this scale."""
|
@@ -563,14 +572,18 @@ def get_transform(self):
|
563 | 572 | def set_default_locators_and_formatters(self, axis):
|
564 | 573 | axis.set(major_locator=AsinhLocator(self.linear_width,
|
565 | 574 | base=self._base),
|
566 |
| - minor_locator=AsinhLocator(self.linear_width, |
567 |
| - base=self._base, |
568 |
| - subs=self._subs), |
569 | 575 | minor_formatter=NullFormatter())
|
570 | 576 | if self._base > 1:
|
571 | 577 | axis.set_major_formatter(LogFormatterSciNotation(self._base))
|
572 | 578 | else:
|
573 | 579 | axis.set_major_formatter('{x:.3g}'),
|
| 580 | + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or |
| 581 | + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): |
| 582 | + axis.set_minor_locator(AsinhLocator(self.linear_width, |
| 583 | + base=self._base, |
| 584 | + subs=self._subs)) |
| 585 | + else: |
| 586 | + axis.set_minor_locator(NullLocator()) |
574 | 587 |
|
575 | 588 |
|
576 | 589 | class LogitTransform(Transform):
|
@@ -660,14 +673,18 @@ def set_default_locators_and_formatters(self, axis):
|
660 | 673 | use_overline=self._use_overline
|
661 | 674 | )
|
662 | 675 | )
|
663 |
| - axis.set_minor_locator(LogitLocator(minor=True)) |
664 | 676 | axis.set_minor_formatter(
|
665 | 677 | LogitFormatter(
|
666 | 678 | minor=True,
|
667 | 679 | one_half=self._one_half,
|
668 | 680 | use_overline=self._use_overline
|
669 | 681 | )
|
670 | 682 | )
|
| 683 | + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or |
| 684 | + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): |
| 685 | + axis.set_minor_locator(LogitLocator(minor=True)) |
| 686 | + else: |
| 687 | + axis.set_minor_locator(NullLocator()) |
671 | 688 |
|
672 | 689 | def limit_range_for_scale(self, vmin, vmax, minpos):
|
673 | 690 | """
|
|
0 commit comments