Closed zachcp closed 9 years ago
So, we made a conscious choice not to do this--@hadley can correct me if I'm mistaken, but I believe a great source of ggplot2's complexity both in terms of user comprehension and implementation, is due to needing to distinguish between scaled and unscaled values.
However, to make it easier to work with colors, we've included a handful of color functions to concisely express your intent--our hope was that this is easy enough that you won't miss ggplot-style automatic color scaling too much. If you're aware of these and it still isn't convenient enough for your tastes, please feel free to reopen this issue.
I'm still working on the docs for the color functions, but the function reference already exists and has examples: ?colorNumeric
Here are a couple more examples that build off yours:
m %>% addCircles(color=~colorFactor("RdYlBu", NULL)(CatVar))
m %>% addCircles(color=~colorNumeric("Greens", NULL)(ConVar))
# Share a color scale between two continuous variables
pal <- colorQuantile("Blues", domain = c(df$ConVar1, df$ConVar2))
m %>%
addCircles(color = ~pal(ConVar1)) %>%
addCircles(color = ~pal(ConVar2))
Thanks for your quick reply @jcheng5 . Seems like fine logic to me and for my usecase I can write a little helper function that will distinguish between my common columns and plot accordingly.
As a small counterargument to your choice, I would suggest that the first thing people will want to do when looking at a new dataset is to color by some variable and having to choose a color scheme is another barrier. However, I was unaware of your helper functions which look to ease the problem considerably.
Perhaps we could make an exception for color. It does seem like numeric()
and factor()
are quite obviously not colors, so there's no danger of mistaking scaled for unscaled data.
Hi Rstudio Team,
Thanks for your great work on this package.
I'd like to request a feature to allow default color handling for any column name that is passed via the scripting interface. Right now the
color
argument works well when there is a string, a vector of colors, or a dataframe column of colors. However if you simply pass the name of any old columnleaflet
cannot handle the data. To me, a best-guess representation of color in the spirit ofggplot
is desirable where leaflet can detect if the column is a string, a categorical variable, or a continuous variable.thanks, zach cp