tdhock / animint

animated and interactive web graphics
146 stars 37 forks source link

stroke-opacity and fill-opacity aesthetics #32

Open srvanderplas opened 9 years ago

srvanderplas commented 9 years ago

Specify stroke-opacity and fill-opacity separately (allowing rectangles to have no fill but still have a border, etc.). These options are available in d3 but are not currently ggplot2 aesthetics.

cpsievert commented 9 years ago

Looks like this is on the TODO list, but to be honest, I think it is more transparent if we translate the TODO list to issues. Thoughts @tdhock?

tdhock commented 9 years ago

Susan, if I understand correctly you would like to specify the transparency/opacity separately for stroke/color and fill? What aethetics do you suggest? aes(alpha_color=1/2, alpha_fill=3/4)? or aes(stroke_opacity=1/2, fill_opacity=3/4)? Can you please provide a concrete example with code and data?

In fact, there is not yet a TODO for that. The TODO that Carson referenced is about aes for different selection states. More generally I think it is fine to move some TODOs to GitHub issues, so go ahead and do that for the ones you think are important.

srvanderplas commented 9 years ago

d3 has options for stroke-opacity and fill-opacity, which I ran into recently because I needed the rectangular outline but not the inside. I worked around it using css and the id aesthetic (awesome, btw - but doesn't work as a constant aesthetic per geom). I'm not particular on the syntax, but it would be nice to be able to specify both options separately. For consistency with R syntax, alpha_color and alpha_fill are probably the best choice.

I'm working on a minimal example of where this would be useful. Will post soon.

On Wed, Nov 19, 2014 at 8:22 AM, Toby Dylan Hocking < notifications@github.com> wrote:

Susan, if I understand correctly you would like to specify the transparency/opacity separately for stroke/color and fill? What aethetics do you suggest? aes(alpha_color=1/2, alpha_fill=3/4)? or aes(stroke_opacity=1/2, fill_opacity=3/4)? Can you please provide a concrete example with code and data?

In fact, there is not yet a TODO for that. The TODO that Carson referenced is about aes for different selection states. More generally I think it is fine to move some TODOs to GitHub issues, so go ahead and do that for the ones you think are important.

— Reply to this email directly or view it on GitHub https://github.com/tdhock/animint/issues/32#issuecomment-63646295.

srvanderplas commented 9 years ago

http://bl.ocks.org/srvanderplas/raw/ecfe137aab991c9eee8d/

This gist contains an example where this feature would be very useful, but is not currently intuitive. A workaround is possible using the aesthetic id="label" and css, but it would be more intuitive to be able to specify the fill and stroke opacity aesthetics within R. Currently, there are cases where it is reasonable to use a rectangle selector (tallrect, for example) but selecting an object distorts other aesthetics because there is no way to turn the fill off entirely.

tdhock commented 9 years ago

For the example you gave I think there is a workaround: have you tried fill="transparent" or fill=NA?

But yes it would still be nice to specify different opacity values for fill and color.

srvanderplas commented 9 years ago

The first plot is fill=NA. fill=transparent works, though. I messed around with fill="none", etc. last night, but didn't try "transparent".

http://bl.ocks.org/srvanderplas/raw/b7ee3272513f79c93d9a/

Still would be good to have the d3 aesthetics that aren't available in R supported, though.

On Wed, Nov 19, 2014 at 10:01 AM, Toby Dylan Hocking < notifications@github.com> wrote:

For the example you gave I think there is a workaround: have you tried fill="transparent" or fill=NA?

But yes it would still be nice to specify different opacity values for fill and color.

— Reply to this email directly or view it on GitHub https://github.com/tdhock/animint/issues/32#issuecomment-63662952.

tdhock commented 8 years ago

looks like in ggplot2 v2.0

alpha now affects both fill and colour aesthetics (#1371).

https://github.com/hadley/ggplot2/blob/master/NEWS.md#default-appearance