Skip to content

Commit ba597de

Browse files
committed
Added AutoLocator for minor ticks and further tweaks of zero-crossing logic
1 parent 0ad43a5 commit ba597de

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

examples/scales/asinh_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import matplotlib.pyplot as plt
4242

4343
# Prepare sample values for variations on y=x graph:
44-
x = np.linspace(-3, 6, 100)
44+
x = np.linspace(-3, 6, 500)
4545

4646
########################################
4747
# Compare "symlog" and "asinh" behaviour on sample y=x graph,

lib/matplotlib/scale.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,9 @@ def get_transform(self):
529529

530530
def set_default_locators_and_formatters(self, axis):
531531
axis.set(major_locator=AsinhLocator(self.linear_width),
532-
major_formatter='{x:.3g}')
532+
minor_locator=AutoLocator(),
533+
major_formatter='{x:.3g}',
534+
minor_formatter=NullFormatter())
533535

534536
class LogitTransform(Transform):
535537
input_dims = output_dims = 1

lib/matplotlib/ticker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ def tick_values(self, vmin, vmax):
26352635
/ self.linear_width)
26362636
ys = np.linspace(ymin, ymax, self.numticks)
26372637
zero_dev = np.abs(ys / (ymax - ymin))
2638-
if (ymin * ymax) < 0 and min(zero_dev) > 0:
2638+
if (ymin * ymax) < 0:
26392639
# Ensure that the zero tick-mark is included,
26402640
# if the axis straddles zero
26412641
ys = np.hstack([ys[(zero_dev > 0.5 / self.numticks)], 0.0])
@@ -2647,7 +2647,7 @@ def tick_values(self, vmin, vmax):
26472647
# Round the data-space values to be intuitive decimal numbers:
26482648
decades = (
26492649
np.where(xs >= 0, 1, -1) *
2650-
np.power(10, np.where(zero_xs, 1.0,
2650+
np.power(10, np.where(zero_xs, 0.0,
26512651
np.floor(np.log10(np.abs(xs)
26522652
+ zero_xs*1e-6))))
26532653
)

0 commit comments

Comments
 (0)