Skip to content

Commit

Permalink
add recipe to plot series objects (#4930)
Browse files Browse the repository at this point in the history
* add recipe to plot series objects

* Update src/types.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* add test

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BeastyBlacksmith and github-actions[bot] authored May 23, 2024
1 parent 6697666 commit a03e19f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ mutable struct Series
plotattributes::DefaultsDict
end

@recipe function f(s::Series)
for (k, v) in s.plotattributes
k in (:subplot, :yerror, :xerror, :zerror) && continue
plotattributes[k] = v
end
()
end

# a single subplot
mutable struct Subplot{T<:AbstractBackend} <: AbstractLayout
parent::AbstractLayout
Expand Down
7 changes: 7 additions & 0 deletions test/test_recipes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
using OffsetArrays

@testset "Series" begin
pl = plot(1:3, yerror = 1)
@test plot(pl[1][1])[1][1][:primary] == true
@test plot(pl[1][2])[1][1][:primary] == false
@test isequal(plot(pl[1][2])[1][1][:y], pl[1][2][:y])
end

@testset "User recipes" begin
struct LegendPlot end
@recipe function f(plot::LegendPlot)
Expand Down

0 comments on commit a03e19f

Please sign in to comment.