Skip to content

Commit 5507cc5

Browse files
committed
Clean up
1 parent f4b7604 commit 5507cc5

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

src/axes.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181
function attr!(axis::Axis, args...; kw...)
8282
# first process args
8383
plotattributes = axis.plotattributes
84-
dummy_attributes = Dict{Symbol, Any}(:plot_object=>first(axis.sps).plt)
84+
dummy_attributes = Dict{Symbol,Any}(:plot_object => first(axis.sps).plt)
8585
for arg in args
8686
process_axis_arg!(plotattributes, arg)
8787
end
@@ -331,12 +331,8 @@ get_ticks(::T, args...) where {T} = error("Unknown ticks type in get_ticks: $T")
331331

332332
_transform_ticks(ticks, axis) = ticks
333333
function _transform_ticks(ticks::AbstractArray, axis)
334-
dummy_attributes = Dict{Symbol, Any}(:plot_object=>first(axis.sps).plt)
335-
return RecipesPipeline._apply_type_recipe(
336-
Dict{Symbol, Any}(:plot_object=>first(axis.sps).plt),
337-
ticks,
338-
axis[:letter]
339-
)
334+
dummy_attributes = Dict{Symbol,Any}(:plot_object => first(axis.sps).plt)
335+
return RecipesPipeline._apply_type_recipe(dummy_attributes, ticks, axis[:letter])
340336
end
341337
_transform_ticks(ticks::NTuple{2,Any}, axis) = (_transform_ticks(ticks[1], axis), ticks[2])
342338

@@ -624,20 +620,16 @@ function round_limits(amin, amax, scale)
624620
amin, amax
625621
end
626622

627-
#process_limits(lims::Tuple{<:Union{Symbol,Real},<:Union{Symbol,Real}}, axis) = lims
628623
process_limits(lims::Symbol, axis) = lims
629624
process_limits(lims::Tuple, axis) = process_limits([lims...], axis)
630625
function process_limits(lims::AVec, axis)
631-
lims = RecipesPipeline._apply_type_recipe(
632-
Dict{Symbol, Any}(:plot_object=>first(axis.sps).plt),
633-
lims,
634-
axis[:letter]
635-
)
626+
dummy_attributes = Dict{Symbol,Any}(:plot_object => first(axis.sps).plt)
627+
lims = RecipesPipeline._apply_type_recipe(dummy_attributes, lims, axis[:letter])
636628
if lims isa Formatted
637629
lims = lims.data
638630
end
639631
length(lims) == 2 || return nothing
640-
all(x -> x isa Union{Symbol, Real}, lims) || return nothing
632+
all(x -> x isa Union{Symbol,Real}, lims) || return nothing
641633
return Tuple(lims)
642634
end
643635
process_limits(lims, axis) = nothing

src/unitful.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ using ..Unitful: Quantity, unit, ustrip, Unitful, dimension, Units, NoUnits
77
using ..RecipesBase
88
export @P_str
99

10-
import ..locate_annotation,
11-
..PlotText, ..Subplot, ..AVec, ..AMat, ..Axis
10+
import ..locate_annotation, ..PlotText, ..Subplot, ..AVec, ..AMat, ..Axis
1211

1312
const MissingOrQuantity = Union{Missing,<:Quantity}
1413

test/test_dates.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ end
1616
@testset "Date xlims" begin
1717
y = [1.0 * i * i for i in 1:10]
1818
x = [Date(2019, 11, i) for i in 1:10]
19-
span = [Date(2019, 10, 31), Date(2019, 11, 11)]
19+
span = (Date(2019, 10, 31), Date(2019, 11, 11))
2020

21-
ref_xlims = Tuple(map(date -> date.instant.periods.value, span))
21+
ref_xlims = map(date -> date.instant.periods.value, span)
2222

2323
pl = plot(x, y, xlims = span, widen = false)
2424
@test Plots.xlims(pl) == ref_xlims
@@ -27,9 +27,9 @@ end
2727
@testset "DateTime xlims" begin
2828
y = [1.0 * i * i for i in 1:10]
2929
x = [DateTime(2019, 11, i, 11) for i in 1:10]
30-
span = [DateTime(2019, 10, 31, 11, 59, 59), DateTime(2019, 11, 11, 12, 01, 15)]
30+
span = (DateTime(2019, 10, 31, 11, 59, 59), DateTime(2019, 11, 11, 12, 01, 15))
3131

32-
ref_xlims = Tuple(map(date -> date.instant.periods.value, span))
32+
ref_xlims = map(date -> date.instant.periods.value, span)
3333

3434
pl = plot(x, y, xlims = span, widen = false)
3535
@test Plots.xlims(pl) == ref_xlims

test/test_recipes.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ end
8686
struct DoubleNumber
8787
x
8888
end
89-
@recipe f(::Type{T}, v::T) where {T<:AbstractArray{DoubleNumber}} = [2*x.x for x in v]
89+
@recipe f(::Type{T}, v::T) where {T<:AbstractArray{DoubleNumber}} = [2 * x.x for x in v]
9090

91-
p = plot(1:3; ylims=DoubleNumber.([0.5, 2.0]), yticks=DoubleNumber.([0.4, 0.8, 1.2]))
91+
p = plot(
92+
1:3;
93+
ylims = DoubleNumber.([0.5, 2.0]),
94+
yticks = DoubleNumber.([0.4, 0.8, 1.2]),
95+
)
9296
@test ylims(p) == (1.0, 4.0)
9397
@test first(first(yticks(p))) == [1.6, 2.4]
9498
end
95-

0 commit comments

Comments
 (0)