MakieOrg / Makie.jl

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

color can not be vector of LinePattern #4029

Open ctarn opened 4 months ago

ctarn commented 4 months 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 4 months ago

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

ctarn commented 4 months 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 4 months ago

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