Skip to content

Commit

Permalink
Fix color piracy in makie.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
jpthiele committed Nov 21, 2024
1 parent 832bac8 commit 35b5981
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,30 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid
end

function update_lines(ctx, newrange)
# No uniform method in Colors to create a color from either tuple or symbol
rgbcol = Colors.RGB{Float64}(0,0,0)
if ctx[:color] isa Tuple{Float64,Float64,Float64}
rgbcol = RGB(ctx[:color][1],ctx[:color][2],ctx[:color][3])
else
rgbcol = parse(Colors.RGB{Float64},ctx[:color])
end

if ctx[:markershape] == :none
#line without marker
for l in newrange
XMakie.lines!(ctx[:scene],
map(a -> a, ctx[:lines][l]);
linestyle = ctx[:linestyle],
linewidth = ctx[:linewidth],
color = RGB(ctx[:color]),)
color = rgbcol)
end
if ctx[:label] != ""
XMakie.scatterlines!(ctx[:scene],
map(a -> a[1:1], ctx[:lines][newrange[begin]]);
linestyle = ctx[:linestyle],
linewidth = ctx[:linewidth],
markersize = 0.1,
color = RGB(ctx[:color]),
color = rgbcol,
label = ctx[:label],)
end
else
Expand All @@ -389,12 +397,12 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid
XMakie.lines!(ctx[:scene],
map(a -> a, ctx[:lines][l]);
linestyle = ctx[:linestyle],
color = RGB(ctx[:color]),
color = rgbcol,
linewidth = ctx[:linewidth],)
# draw markers without label
XMakie.scatter!(ctx[:scene],
map(a -> a[1:ctx[:markevery]:end], ctx[:lines][l]);
color = RGB(ctx[:color]),
color = rgbcol,
marker = ctx[:markershape],
markersize = ctx[:markersize],)
end
Expand All @@ -409,8 +417,8 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid
linewidth = ctx[:linewidth],
marker = ctx[:markershape],
markersize = ctx[:markersize],
markercolor = RGB(ctx[:color]),
color = RGB(ctx[:color]),
markercolor = rgbcol,
color = rgbcol,
label = ctx[:label],)
end
end
Expand All @@ -437,7 +445,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grids, parentgrid
# Plot size
XMakie.scatter!(ctx[:scene],
[Point2f(xmin, ymin), Point2f(xmax, ymax)];
color = :white,
color = parse(RGB{Float64},:white),
markersize = 0.0,
strokewidth = 0,)

Expand Down

0 comments on commit 35b5981

Please sign in to comment.