Opacity in Gadfly plots

471 views
Skip to first unread message

Jordan Meyer

unread,
Feb 25, 2015, 11:13:38 PM2/25/15
to julia...@googlegroups.com
I was playing around with using Gadfly's Geom.ribbon to make plots showing integrals as shaded areas under curves. Sometimes you might have two curves in separate colors where parts of the shaded regions under both curves overlap. If the shading that is being done by Geom.ribbon is not completely opaque, you should then get an overlap region where the shading color is a blend of the two original ones. I thought this behavior would result by default as a similar thing is what appears to be going on in the example for Geom.ribbon in the (old) Gadfly doc here: https://dcjones.github.io/Gadfly.jl/geom_ribbon.html. But the following example I tried gives this instead:

using Gadfly, DataFrames, Distributions
d1
= Normal(-1); d2 = Normal(1);
x
=-4:0.01:4
y1
= pdf(d1,x); y2 = pdf(d2,x);
df1
= DataFrame(x=x,y=y1,ymin=0.0,ymax=y1,d="d1");
df2
= DataFrame(x=x,y=y2,ymin=0.0,ymax=y2,d="d2");
df
= vcat(df1,df2)
p
= plot(df, x=:x, y=:y, ymin=:ymin, ymax=:ymax, color=:d, Geom.line, Geom.ribbon)
draw
(PNG("test1.png", 12cm, 6cm), p)

Changing what I believe is the relevant Theme parameter to explicitly specify an opacity doesn't change the output:

p = plot(df, x=:x, y=:y, ymin=:ymin, ymax=:ymax, color=:d, Geom.line, Geom.ribbon, Theme(lowlight_opacity=0.5))

I then noticed that the same Geom.ribbon example on the new Gadfly site also doesn't have the transparency effect the old example did: http://gadflyjl.org/geom_ribbon.html.

So opacity level settings are documented and appear to have been working at some point but aren't now. Anyone happen to know what the situation with this is?

Kevin Squire

unread,
Feb 26, 2015, 11:58:19 AM2/26/15
to julia...@googlegroups.com
Hi Jordan,

I don't have an answer, but if you don't get a response here, I would suggest opening up an issue with Gadfly.jl. 

Cheers,
   Kevin 
Reply all
Reply to author
Forward
0 new messages