No control of alpha with filled points

7 views
Skip to first unread message

Winston Chang

unread,
Jun 5, 2009, 2:26:48 AM6/5/09
to ggplot2
Because I like the way they look for plots with points and lines, I've been making some graphs with the filled shapes (21-25). This is a pretty minor bug, but I've found that the fill doesn't seem to follow the specified alpha level, although the outline does. Or maybe it's a feature.

Attached are a scatterplot (generated by the code below) and a zoomed-in view of a PDF with these shapes. In the zoomed-in view, you can see the edge of the white circle underneath the green ring.

df <- data.frame(xval=rnorm(100), yval=rnorm(100))
ggplot(df, aes(x=xval, y=yval)) +
    geom_point(size=5, shape=21, colour="black", fill="white", alpha=.5)


point_fill_alpha.png

point_fill_zoom.png
point_fill_zoom.png
point_fill_alpha.png

baptiste auguie

unread,
Jun 5, 2009, 4:05:53 AM6/5/09
to Winston Chang, ggplot2
> point_fill_alpha.png
>
> point_fill_zoom.png
>
> >

Hi,

I'm not sure I'm following you --- is it the same effect as in the
example attached (the border of the point is partially covering the
interior of the disc). It seems to me that it's a characteristic of the
point symbols to have the line expand symmetrically inside and outside
when increasing the linewidth, and presumably the border is drawn on top
of the interior region at the engine level. But perhaps I misunderstood
your query?

# code

library(ggextra)
qplot(0, 0, geom="blank")+
geom_point2(size=50, shape=21, fill=alpha("grey", 0.5), col=alpha("red",
0.2), lex=20) +
theme_minimal()



Best,

baptiste


Picture 4.png

hadley wickham

unread,
Jun 5, 2009, 9:15:14 AM6/5/09
to baptiste auguie, Winston Chang, ggplot2
> I'm not sure I'm following you --- is it the same effect as in the
> example attached (the border of the point is partially covering the
> interior of the disc). It seems to me that it's a characteristic of the
> point symbols to have the line expand symmetrically inside and outside
> when increasing the linewidth, and presumably the border is drawn on top
> of the interior region at the engine level. But perhaps I misunderstood
> your query?

Winston was using the alpha _aesthetic_, and he's right in expecting
that it should affect the fill colour as well. I've fixed it in the
development version. Unfortunately there's not much I can do about
the slightly strange appearance that results.

Hadley


--
http://had.co.nz/

baptiste auguie

unread,
Jun 5, 2009, 10:35:34 AM6/5/09
to ggplot2

Sorry I misinterpreted the example you provided. The good news is, your
issue can be addressed, while the one I had made up out of the blue
would be more problematic!

Best,

baptiste
> point_fill_alpha.png
>
> point_fill_zoom.png
>
> >

Reply all
Reply to author
Forward
0 new messages