# How to get empty markers, Plots, gr() backend

**URL:** <https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069>\
**Category:** General Usage\
**Tags:** plotting, development\
**Created:** [January 25, 2019, 4:28am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069 "2019-01-25T04:28:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 25, 2019, 4:28am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/1 "2019-01-25T04:28:40Z")

</div>

If I have something like this

```julia
plot(x, y, shape = :rect, m = (5, :black, stroke(1, :red))

```

the second option in `m` fills my marker with that color. But what I want is an empty marker, not white. Empty! Is this possible here?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [January 25, 2019, 7:20am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/2 "2019-01-25T07:20:06Z")

</div>

You can’t - it’s a weakness of the current gr backend to Plots. The other backends will do this if you set `markeralpha = 0`.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 25, 2019, 2:49pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/3 "2019-01-25T14:49:07Z")

</div>

Too bad. I really like `gr`. However, if I change to `pyplot`, i.e.

```julia
using Plots
pyplot()
data = rand(10,2)
plot(data[:,1], data[:,2], m = (8, 0.0, :red, stroke(1, :blue)), 
    framestyle=:box, grid = false, size = (400,400))

```

![48%20AM](https://global.discourse-cdn.com/julialang/original/3X/f/4/f41ab66113b9c184f8634296100f266c1675a8f1.png)  
where now the second option in `m` is the `markeralpha = 0`, it turns out that the **label is not right**. The label should be a circle (the stroke) and a line. Any ideas?

---

<div class="post-metadata">

**Author:** ![dmolina](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmolina/32/5246_2.png) [@dmolina](https://discourse.julialang.org/u/dmolina)\
**Post date:** [January 25, 2019, 6:48pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/4 "2019-01-25T18:48:27Z")

</div>

I am not actually sure about that are you looking for. I guess when you talk about label you want to say legend. In that case, in  
[http://docs.juliaplots.org/latest/examples/pyplot/#arguments](http://docs.juliaplots.org/latest/examples/pyplot/#arguments)  
there is an example, adding the shape in marker (with :circle). Maybe it could work for you.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 25, 2019, 7:03pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/5 "2019-01-25T19:03:28Z")

</div>

Yes, I mean legend. The problem is that if you set in the example that you mention the

```julia
markeralpha =0

```

then the whole marker goes away in the legend. Ideally I will hope to see just the stroke and the corresponding line.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 8, 2019, 8:28pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/6 "2019-09-08T20:28:21Z")

</div>

I realize this is an old topic, but I am running into the same issue. Is there a way to obtain the correct legend?

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [September 8, 2019, 8:53pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/7 "2019-09-08T20:53:54Z")

</div>

The best you can do with Plots, I think is the following. If more control is needed, then use matplotlib.

```julia
using Plots
pyplot()
data = rand(10,2)
color = :red
plot(data[:,1], data[:,2], m = (7, :white, stroke(1, color)),
    lw =1.0, c = color, linestyle =:dash, framestyle=:box, 
    grid = false, size = (400,400))

```

 ![32](https://global.discourse-cdn.com/julialang/original/3X/a/1/a1b348d367fd8459896353d1d0f98ea3e7aa1f4d.png)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [September 9, 2019, 5:50am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/8 "2019-09-09T05:50:01Z")

</div>

That’s not true, Plots supports empty markers with `markercolor = :transparent`. But it is not supported by the GR backend.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [September 9, 2019, 6:52am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/9 "2019-09-09T06:52:56Z")

</div>

Indeed, setting `markercolor = :transparent` gives the correct behavior for the legend and the plot with pyplot. i.e., `m = (5, :transparent, stroke(1, color))` .

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [March 26, 2020, 9:57am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/10 "2020-03-26T09:57:31Z")

</div>

any workaround for this?

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 16, 2022, 10:08pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/11 "2022-02-16T22:08:47Z")

</div>

GR still doesn’t support hollow markers. Sad… I like GR because, for 2D figures, I think GR is more elegant…

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 16, 2022, 10:57pm UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/12 "2022-02-16T22:57:39Z")

</div>

If one is not too choosy, pseudo-transparency is possible:

```julia
using Plots; gr()
M = rand(10,2)
scatter(M[:,1], M[:,2], mc=:white, msc=:darkred, msw=2, label="Am I transparent?")
plot!(M[:,1], M[:,2], ls=:dot, c=:red, framestyle=:box, grid = false)

```

 ![Plots_gr_pseudo_transparent_markers](https://global.discourse-cdn.com/julialang/original/3X/b/2/b29f18bc2a1dd680fc0578fb340c354e0e25607f.png)

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 17, 2022, 8:32am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/13 "2022-02-17T08:32:58Z")

</div>

hhhh.  
But the marker will cover the lines (if there’s other data behind them)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 17, 2022, 10:04am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/14 "2022-02-17T10:04:22Z")

</div>

Because I knew you would not be happy see code below, adapted from this [great Plots.jl solution](https://discourse.julialang.org/t/how-to-plot-circles-with-given-radii-using-plots/47845/9).

 ![Plots_gr_transparent_markers_as_Shapes](https://global.discourse-cdn.com/julialang/original/3X/7/3/73182061b06c8a64f8a61f3f2a6b1798067189f7.png)

> **Plots.jl gr() code**
>
> ```julia
> using Plots; gr()
> 
> circle(x, y, r) = Plots.Shape(r*sind.(0:10:360) .+ x, r*cosd.(0:10:360) .+ y)
> 
> M = rand(12,2)
> circles = circle.([M[:,1], M[:,2]]..., (0.02,))
> p = plot(M[:,1], M[:,2], ls=:dot, c=:red, framestyle=:box, grid=false)
> plot!(circles, ratio=1, fc=:transparent, lc=:darkred, lw=1, label=false)
> scatter!([-1e16], [circles[1].y[1]], mc=:white, msc=:darkred, lw=1, label="I am transparent!",
> xlims=Plots.xlims(p), ylims=Plots.ylims(p))
> 
> ```

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 17, 2022, 10:56am UTC](https://discourse.julialang.org/t/how-to-get-empty-markers-plots-gr-backend/20069/15 "2022-02-17T10:56:39Z")

</div>

Plots actually has an exported `partialcircle` function that can also draw full circles.
