-
Notifications
You must be signed in to change notification settings - Fork 46
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
Legend additionally shows marker for Lines
and line for Scatter
plot
#576
Comments
It's not checked if data for some group is nonempty before its legend marker is added. And because both of your plots share the same color scale, you get both entries for both. I'm not sure if legend markers should be conditional of some data in the respective group. It's conceivable to have a plot type that shows something even when it has no data.. |
Ah, so it's not relevant that I wonder, is there a better way to achieve what I actually wanted to do here and for which I used the Initially, I had tried e.g. julia> spec1 = data(df1) * mapping(:x, :y, layout = :group) * visual(Scatter; color = Cycled(1));
julia> spec2 = data(df2) * mapping(:x, :y, layout = :group) * visual(Lines; color = Cycled(2));
julia> draw(spec1 + spec2)
ERROR: Attribute `color` was passed with an explicit `Cycled` value, but color is not specified in the cycler for this plot type Scatter{Tuple{Vector{Point{2, Float64}}}}.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] add_cycle_attributes!(plot::Any, cycle::Cycle, cycler::Makie.Cycler, palette::Attributes)
@ Makie ~/.julia/packages/Makie/6c4lt/src/makielayout/blocks/axis.jl:725
[3] add_cycle_attribute!(plot::Scatter{Tuple{Vector{Point{2, Float64}}}}, scene::Scene, cycle::Cycle)
@ Makie ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:5
[4] add_cycle_attribute!(plot::Scatter{Tuple{Vector{Point{2, Float64}}}}, scene::Scene)
@ Makie ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:3
[5] color_and_colormap!(plot::Scatter{Tuple{Vector{Point{2, Float64}}}}, colors::Observable{Any})
@ Makie ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:12
[6] color_and_colormap!(plot::Scatter{Tuple{Vector{Point{2, Float64}}}})
@ Makie ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:10
[7] calculated_attributes!
@ ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:64 [inlined]
[8] connect_plot!(parent::Scene, plot::Scatter{Tuple{Vector{Point{2, Float64}}}})
@ Makie ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:388
[9] plot!
@ ~/.julia/packages/Makie/6c4lt/src/interfaces.jl:412 [inlined]
[10] plot!(ax::Axis, plot::Scatter{Tuple{Vector{Point{2, Float64}}}})
@ Makie ~/.julia/packages/Makie/6c4lt/src/figureplotting.jl:412
[11] plot!(ae::AxisEntries)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/entries.jl:82
[12] foreach(f::typeof(plot!), itr::Matrix{AxisEntries})
@ Base ./abstractarray.jl:3187
[13] plot!(fig::Figure, d::Layers, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:21
[14] plot!
@ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:16 [inlined]
[15] (::AlgebraOfGraphics.var"#374#379"{Dictionaries.Dictionary{…}, Dictionaries.Dictionary{…}, Dictionaries.Dictionary{…}, Dictionaries.Dictionary{…}, Layers, AlgebraOfGraphics.Scales, AlgebraOfGraphics.FigureSettings})(f::Figure)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:162
[16] update
@ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:10 [inlined]
[17] _draw(d::Layers, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{…}, figure::Dictionaries.Dictionary{…}, facet::Dictionaries.Dictionary{…}, legend::Dictionaries.Dictionary{…}, colorbar::Dictionaries.Dictionary{…})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:161
[18] _draw
@ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:154 [inlined]
[19] draw(d::Layers, scales::AlgebraOfGraphics.Scales; axis::@NamedTuple{}, figure::@NamedTuple{}, facet::@NamedTuple{}, legend::@NamedTuple{}, colorbar::@NamedTuple{}, palette::Nothing)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:85
[20] draw
@ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:75 [inlined]
[21] draw(d::Layers)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:75
[22] top-level scope
@ REPL[29]:1
Some type information was truncated. Use `show(err)` to see complete types. |
The cycler is actually specifically disabled in AoG so that you don't get unintended colors where you don't want any. I guess currently the easiest is to retrieve the palette manually and use p = Makie.current_default_theme()[:palette][:color][]
pregrouped([1:2], [1:2]) * visual(Scatter, color = p[1], label = "A") +
pregrouped([3:4], [3:4]) * visual(Lines, color = p[2], label = "B") |> draw |
Bug description
The legend shows markers (lines) even though the corresponding plots do not show any markers (lines).
Steps to reproduce
Images
The figure contains a scatter plot ("Data 1") and a line plot ("Data 2"). However, the legend displays both plots as combined scatter + lines plots:
Version info
Please include the output of
versioninfo()
andPkg.status()
for the environmentwhere the issue occurred.
The text was updated successfully, but these errors were encountered: