prefer multiples of 3 for log10

This commit is contained in:
Daniel Schwabeneder 2021-06-13 22:44:50 +02:00
parent 95d6cf518e
commit 0029c766ed

View File

@ -168,22 +168,27 @@ function optimal_ticks_and_labels(ticks, alims, scale, formatter)
end end
# get a list of well-laid-out ticks # get a list of well-laid-out ticks
smin, smax = sf(amin), sf(amax)
if ticks === nothing if ticks === nothing
scaled_ticks = optimize_ticks( scaled_ticks = optimize_ticks(
sf(amin), smin,
sf(amax); smax;
k_min = 4, # minimum number of ticks k_min = 4, # minimum number of ticks
k_max = 8, # maximum number of ticks k_max = 8, # maximum number of ticks
Q = if scale in _logScales Q = if scale in _logScales
if scale === :log10 && smax - smin > 6
[(1.0,1.0), (3.0, 0.9)]
else
[(1.0, 1.0), (5.0, 0.9), (2.0, 0.7)] [(1.0, 1.0), (5.0, 0.9), (2.0, 0.7)]
end
else else
[(1.0,1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)] [(1.0,1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)]
end, end,
)[1] )[1]
elseif typeof(ticks) <: Int elseif typeof(ticks) <: Int
scaled_ticks, viewmin, viewmax = optimize_ticks( scaled_ticks, viewmin, viewmax = optimize_ticks(
sf(amin), smin,
sf(amax); smax;
k_min = ticks, # minimum number of ticks k_min = ticks, # minimum number of ticks
k_max = ticks, # maximum number of ticks k_max = ticks, # maximum number of ticks
k_ideal = ticks, k_ideal = ticks,
@ -191,7 +196,11 @@ function optimal_ticks_and_labels(ticks, alims, scale, formatter)
# chosen ticks is not too much bigger than amin - amax: # chosen ticks is not too much bigger than amin - amax:
strict_span = false, strict_span = false,
Q = if scale in _logScales Q = if scale in _logScales
if scale === :log10 && smax - smin > 6
[(1.0,1.0), (3.0, 0.9)]
else
[(1.0, 1.0), (5.0, 0.9), (2.0, 0.7)] [(1.0, 1.0), (5.0, 0.9), (2.0, 0.7)]
end
else else
[(1.0,1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)] [(1.0,1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)]
end, end,