Reputation: 523
I am using ggplot to make a scatter plot
I use this command
ggplot(df,aes(x=meanwt, y=meanko,color=threshold)) + geom_point(size=1) + geom_smooth(method=lm,se=FALSE)+
theme_classic()
This creates a scatter plot in 2 colors based on my threshold
column in the file. How can I get the hexadecimal notations for those colors??
Any help would be appreciated.
Thanks
Upvotes: 0
Views: 215
Reputation: 5696
As the data is not available, the following example is based on open dataset:
library(ggplot2)
gplot <- ggplot(mpg, aes(x = displ, y = hwy, colour = class)) +
geom_point(size=1) +
geom_smooth(method = lm, se = FALSE) +
theme_classic()
gplot
You could get the hexadecimal notations of those colors as:
unique(ggplot_build(gplot)$data[[1]]["colour"])
Output:
colour
1 #C49A00
16 #53B400
19 #FB61D7
24 #F8766D
38 #00C094
49 #00B6EB
91 #A58AFF
Upvotes: 1