Closed SathiyaNManivannan closed 3 years ago
Hello!
The whole purpose of geom_scattermost
is to circumvent much of the ggplot machinery (which is comparatively slow) to gain speed. In turn, ggplot cannot compute any point-related values. Your choices are either to compute the color scales manually, or use geom_scattermore
.
This works for me for the continuous colors:
library(scattermore)
library(ggplot2)
d <- data.frame(x=rnorm(100), y=rnorm(100), val=runif(100))
ggplot(d, aes(x,y,color=val)) +
geom_scattermore(pointsize=5, pixels=c(1024,1024)) +
scale_color_gradientn(colors=scales::hue_pal()(30))
...and this works for the discrete colors:
library(scattermore)
library(ggplot2)
d <- data.frame(x=rnorm(100), y=rnorm(100), val=factor(sample(5,100,replace=T)))
ggplot(d, aes(x,y,color=val)) +
geom_scattermore(pointsize=5, pixels=c(1024,1024)) +
scale_color_brewer(palette='Spectral')
Thank you for your kind and prompt response! Would it be possible to get a color guide or a legend for scattermoreplot() or geom_scattermore()? when using these plot appears without any way to assess color assignment to different points.
Plotting with geom_scattermore()
should have the color guide added automagically from ggplot, as above. For scattermoreplot()
I'm not sure -- it is base R plotting. You might need to call legend()
manually there, such as they do it on this link: http://www.sthda.com/english/wiki/add-legends-to-plots-in-r-software-the-easiest-way .
Closing this to keep the repo tidy, feel free to reopen with any more questions/hints/issues :]
Hi, I am trying to see if it would be possible to change the colors in Scattermost with hue_pal(). When using discrete data, where the number of colors required > 10, the colors seem to be recycled. I tried scale_color_manual(values = scales::hue_pal()(30)), but that seems to be ignored by Scattermost Also, the addition of a color guide for discrete scale values like scale_color_discrete() will be useful. Thank you!