Merge pull request #3105 from daschw/discrete-ticks
more regular automatic categorical ticks
This commit is contained in:
commit
2a4f00b80a
@ -227,8 +227,9 @@ function get_ticks(sp::Subplot, axis::Axis; update = true)
|
|||||||
if !isempty(dvals)
|
if !isempty(dvals)
|
||||||
# discrete ticks...
|
# discrete ticks...
|
||||||
n = length(dvals)
|
n = length(dvals)
|
||||||
rng = if ticks == :auto
|
rng = if ticks == :auto && n > 15
|
||||||
Int[round(Int,i) for i in range(1, stop=n, length=min(n,15))]
|
Δ = ceil(Int, n / 10)
|
||||||
|
Δ:Δ:n
|
||||||
else # if ticks == :all
|
else # if ticks == :all
|
||||||
1:n
|
1:n
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,3 +12,12 @@ end
|
|||||||
@test plot(1, axis=nothing)[1][:xaxis][:ticks] == []
|
@test plot(1, axis=nothing)[1][:xaxis][:ticks] == []
|
||||||
@test plot(1, axis=nothing)[1][:yaxis][:ticks] == []
|
@test plot(1, axis=nothing)[1][:yaxis][:ticks] == []
|
||||||
end # testset
|
end # testset
|
||||||
|
|
||||||
|
@testset "Categorical ticks" begin
|
||||||
|
p1 = plot('A':'M', 1:13)
|
||||||
|
p2 = plot('A':'Z', 1:26)
|
||||||
|
p3 = plot('A':'Z', 1:26, ticks = :all)
|
||||||
|
@test Plots.get_ticks(p1[1], p1[1][:xaxis])[2] == string.('A':'M')
|
||||||
|
@test Plots.get_ticks(p2[1], p2[1][:xaxis])[2] == string.('C':3:'Z')
|
||||||
|
@test Plots.get_ticks(p3[1], p3[1][:xaxis])[2] == string.('A':'Z')
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user