Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seriescolor in recipe is ignored #1520

Closed
yakir12 opened this issue May 10, 2018 · 6 comments
Closed

seriescolor in recipe is ignored #1520

yakir12 opened this issue May 10, 2018 · 6 comments
Labels

Comments

@yakir12
Copy link
Contributor

yakir12 commented May 10, 2018

@mkborregaard found out that the following doesn't plot in red (this is from my question on Discourse):

@recipe function f(::Type{Val{:home}}, x,y,z)
       seriescolor := :red
       markershape := :star5
       seriestype := :scatter
       x,y
  end

plot(rand(5), st = :home)
@mkborregaard
Copy link
Member

I also tried the more specific markercolor, which fails with error message:

Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: MethodError: no method matching alpha(::Symbol)
Closest candidates are:
  alpha(::ColorTypes.AGray32) at /Users/michael/.julia/v0.6/ColorTypes/src/traits.jl:11
  alpha(::ColorTypes.ARGB32) at /Users/michael/.julia/v0.6/ColorTypes/src/traits.jl:10
  alpha(::ColorTypes.RGB24) at /Users/michael/.julia/v0.6/ColorTypes/src/traits.jl:9
  ...

@daschw
Copy link
Member

daschw commented May 10, 2018

The issue is the order in the pipeline in https://github.com/JuliaPlots/Plots.jl/blob/master/src/plot.jl#L219-L236: At first the defaults are applied including matching :auto linecolors etc. with the corresponding seriescolors. Then the seriesrecipe is applied. If this changes e.g. the seriescolor, linecolor still holds the default seriescolor from before.
We could try reversing the order, but it might not be that straightforward and I'm not sure if this could cause other issues.
Otherwise, series recipes really should specify the most specific argument.
@mkborregaard's example from above should be fixed by #1522
However, there's still an issue, for instance, with

gr()
@recipe function f(::Type{Val{:test}}, x,y,z)
       markercolor := 3
       seriestype := :scatter
       x,y,z
end
plot(1:5, st = :test)

markercolor = 3 would be replaced by the 3rd color of the default palette in _add_defaults!, which is however called before the series recipe is processed. Hence gr.jl and finally alpha(c) gets markercolor = 3, which it cannot handle:

plot(1:5, st = :test)
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: MethodError: no method matching plot_color(::Int64)
Closest candidates are:
  plot_color(::Any, ::Void) at /home/dani/.julia/v0.6/PlotUtils/src/colors.jl:15
  plot_color(::Any, ::Number) at /home/dani/.julia/v0.6/PlotUtils/src/colors.jl:18
  plot_color(::Symbol) at /home/dani/.julia/v0.6/PlotUtils/src/colors.jl:6
  ...

We could go along and fix this and similar future issues with separate fix in the way of #1522, but getting the order right might be the more sustainable solution.

@mkborregaard
Copy link
Member

Wow, great work @daschw :-O 🎉

@yakir12
Copy link
Contributor Author

yakir12 commented May 11, 2018

Like assigning "specificity" values to attributes and sorting by that?

daschw added a commit that referenced this issue May 18, 2018
update series attributes after processing series recipes fix (#1520)
@yakir12
Copy link
Contributor Author

yakir12 commented May 25, 2018

After (my) last update it now works! So I'm closing this 😄

@yakir12 yakir12 closed this as completed May 25, 2018
@daschw
Copy link
Member

daschw commented May 25, 2018

Oh, thanks, yes #1523 should have fixed it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants