MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.37k stars 302 forks source link

color can not be vector of LinePattern #4029

Open ctarn opened 1 month ago

ctarn commented 1 month ago

When I specify the color of plots such as pie, it will run into a StackOverflowError:

import Makie, CairoMakie

fig = Makie.Figure()
ax = Makie.Axis(fig[1, 1]; autolimitaspect=1)
lp = [Makie.LinePattern(; direction=Makie.Vec2f(1, -1), width=2, tilesize=(12, 12), linecolor=:white, background_color=c) for c in Makie.wong_colors()]
Makie.pie!(ax, Vector(2:8); color=lp)

display(fig)
ERROR: StackOverflowError:
Stacktrace:
 [1] float32type(::Type{DataType}) (repeats 79984 times)
   @ Makie ~/Documents/Projects/Makie.jl/src/conversions.jl:704

Thus we have to draw such a plot many times to attach a LinePattern:

import Makie, CairoMakie

fig = Makie.Figure()
ax = Makie.Axis(fig[1, 1]; autolimitaspect=1)

vs = Vector(2:8)
lp = Makie.LinePattern(; direction=Makie.Vec2f(1, -1), width=2, tilesize=(12, 12), linecolor=:white, background_color=:transparent)
# draw the inner pie twice since `color` can not be vector of `LinePattern` currently
Makie.pie!(ax, vs; color=Makie.wong_colors()[eachindex(vs)])
Makie.pie!(ax, vs; color=lp)

display(fig)

It would be much more complex if we wanted to use different LinePatterns for different parts.

SimonDanisch commented 1 month ago

Until we have support in the backends for one linepattern per poly, we should at least throw a proper error...

ctarn commented 1 month ago

Thank you! Now we can alternatively plot each part at one time respectively (in the same axis), e.g., the example. How far are we from one linepattern per poly?

SimonDanisch commented 1 month ago

It's not on any roadmap, should probably take a day of work or so ;)