hrbrmstr / streamgraph

:wavy_dash: htmlwidget for creating streamgraph visualizations in R
http://hrbrmstr.github.io/streamgraph/
Other
148 stars 49 forks source link

FR: Manually specifiy colors provided to sg_colors #5

Closed jemus42 closed 9 years ago

jemus42 commented 9 years ago

Consider the example data:

ggplot2::movies %>%
  select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) %>% head

  year       genre n
1 1893      Action 0
2 1893   Animation 0
3 1893      Comedy 0
4 1893       Drama 0
5 1893 Documentary 0
6 1893     Romance 0

I would like to manually specifiy the colour for each value of genre instead of relying on a predefined palette. A named vector would suffice, such as:

c(Action = "black", Animation = "grey", Comedy = "blue", …)

This would allow greater customizability of the output, and also be more intuitive for people like me, who are used to ggplot2 and it's scale specifications.

hrbrmstr commented 9 years ago

definitely doable. I was thinking of a few sg_color_ functions (e.g. sg_color_brewer, sg_color_tableau, sg_color_manual) and also renaming them to sg_fill_). thx.

jemus42 commented 9 years ago

Sounds nice, looking forward to it \o/

hrbrmstr commented 9 years ago

the 0.5 push I just made might fill the gap for explicit categorical assignment of manual colors. per the documentation on sg_fill_manual, the streamgraph javascript code sorts the categorical values before mapping to the color palette, so the assignment is deterministic, just not explicit.

abresler commented 9 years ago

Take a look at ggthemes bob they have a bunch of great color palette I'm sure you could borrow same with Wes Anderson

Alex Bresler

ASBC LLLC asbcllc.com 917-455-0239

abresler@asbcllc.com @abresler On Feb 16, 2015 6:51 AM, "boB Rudis" notifications@github.com wrote:

definitely doable. I was thinking of a few sgcolor functions (e.g. sg_color_brewer, sg_color_tableau, sg_color_manual) and also renaming them to sgfill). thx.

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/streamgraph/issues/5#issuecomment-74497605.

hrbrmstr commented 9 years ago

that's where I got Tableau from; and the wes anderson are sweet. looks like all one needs to do to use them in here is something like sg_fill_manual(values=wes_palette("GrandBudapest"))

hrbrmstr commented 9 years ago

Closing issue for basic feature creation. Will look to added named support in a future release.