Julia Plots circular marker with no fill (transparent inside)

Hi,

I’d like to make a circular marker without an interior color.

I tried several things including this but didn’t work yet.

julia> using Plots

julia> a, b = [1], [1]
([1], [1])

julia> scatter(a, b; markeralpha=0, markerstrokealpha=1, markerstrokecolor=:blue)

julia> # transparent marker

julia> scatter(a, b; markercolor=nothing, markerstrokecolor=:blue)

julia> # interior is in black

What should I do?

It’s been a while since I used Plots, but have you tried an RGBA color? Eg markercolor=RGBA(1,1,1,0)

I think it’s white, not transparent.

julia> using Plots

julia> a, b = [1], [1]
([1], [1])

julia> c, d = [1.1], [1.1]
([1.1], [1.1])

julia> fig = plot(; xlim=(0, 10), ylim=(0, 10))

julia> scatter!(a, b; markercolor=RGBA(1, 1, 1, 0), markersize=10)

julia> scatter!(c, d; markercolor=RGBA(1, 1, 1, 0), markersize=10)

image

It’s not supported by the default GR backend, see past discussion with workarounds and GitHub issue.

The easiest is to use another Plots.jl backend if that works for you. Or if you want to try Makie you can do something like scatter(data, color=:transparent, strokecolor=:blue, strokewidth=2).

2 Likes