Plots.jl: Different transparency for markers face and edge

Created on 3 Apr 2018  路  5Comments  路  Source: JuliaPlots/Plots.jl

I want to highlight something in an existing plot by circling it and annotating that. Something like this:
bitmap
I tried to just add a marker with a transparent face-color with this (under a gr backend):

plot(rand(RGB, 10, 10))
scatter!(9*rand(10) + 1, leg=false, marker = (20, 0.0, stroke(3, 1.0, :black)))

But this doesn't work on the rendered window nor on the saved png.

bug

All 5 comments

Yes, it looks like the markerstroke values override the marker values:

scatter(rand(10), markeralpha = 0.2, ms = 20)

skaermbillede 2018-04-03 kl 13 53 50

scatter(rand(10), markeralpha = 0.2, ms = 20, markerstrokealpha = 1)

skaermbillede 2018-04-03 kl 13 54 30

Just a hopefully helpful note to anyone stumbling here, using an RGBA works for the annotations:

annotate!(x, y, text("half transparent red label", RGBA(1,0,0, 0.5)))

a

The problem (at least) for GR is that in the backend code in order to get a stroke, at first a slightly bigger marker with the :markerstroke color attributes is drawn and then on top the interior with the :markercolor attributes is drawn. Hence, if you reduce :markeralpha, the :markerstrokecolor shines through.
I have not yet found a workaround for this. The only thing I can think of for now is replacing all the markers with Plots.Shapes.

Ugh, that's unfortunate. Replacing markers with Shapes is likely to really slow down plotting.

Of course @yakir12 's original use case can be solved by plotting a circle shape. (e.g. plot(Plots.partialcircle(0, 2蟺, 100)) if the aspect ratio is 1).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kersulis picture kersulis  路  5Comments

Cody-G picture Cody-G  路  4Comments

kleinschmidt picture kleinschmidt  路  3Comments

cortner picture cortner  路  4Comments

lstagner picture lstagner  路  5Comments