Makie - Plotting hatched polygons in CairoMakie

Hi!

I’m looking to reimplement various tools I have using python+matplotlib to julia+makie. Most of these deal with stellar astrophysics. One particular one is a plotting tool meant to post-process simulation data into one particular type of plot:

https://github.com/orlox/mkipp

The core of what I need here is to make arbitrarily shaped hatched regions with holes. Using GLMakie I’ve found the snippet below can do the job:

using GLMakie
using Makie

f = Figure(resolution=(500,500))
Axis(f[1, 1])

pat = Makie.Pattern("+")

# polygon with hole
p = Makie.GeometryBasics.Polygon(
    Point2f[(0, 0), (3, 0), (3, 3), (0, 3)],
    [Point2f[(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]]
)

poly!(p, color=pat)

save("figure.png", f)

However, I need to use CairoMakie as well, since vector graphics support is important.The same code switched to CairoMakie gives me instead an error:

Unsupported Color type: Makie.LinePattern{ColorTypes.RGBA{Float32}}

Is this just a feature that is yet to be implemented in CairoMakie? If so, is there any workaround?

Thanks for any help!

It’s just not implemented, yes. If you want to try, it would probably not be too difficult to add a dispatch method for LinePattern with a Cairo implementation.

2 Likes