From a03e19f381b9e4d72f43785771f06fa0ab974224 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 23 May 2024 18:57:23 +0200 Subject: [PATCH] add recipe to plot series objects (#4930) * 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> --- src/types.jl | 8 ++++++++ test/test_recipes.jl | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/types.jl b/src/types.jl index 6dc6067e2..c94571d71 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 diff --git a/test/test_recipes.jl b/test/test_recipes.jl index a7fe5007f..9e3580483 100644 --- a/test/test_recipes.jl +++ b/test/test_recipes.jl @@ -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)