hrbrmstr / ggalt

:earth_americas: Extra Coordinate Systems, Geoms, Statistical Transformations & Scales for 'ggplot2'
https://cran.r-project.org/web/packages/ggalt/vignettes/ggalt_examples.html
Other
654 stars 99 forks source link

problems with colors in geom_encirce() #79

Open danielsangarci opened 2 years ago

danielsangarci commented 2 years ago

Hello,

I would like to ask you about how I could I manually change the color of the circles I get with geom_encircle. The colors I get in the circles does not match with the ones I set in the dots and I cannot manage to change it.

I share my code and the graph I get to show you my problem with the colors

plot1m <- ggplot(fit1m.plot, aes(x=comp1, y=comp2, color=factor(pop_year, level = c("NL2020", "NL1996", "PL1990", "PL2003", "PL2019"))))+  
geom_point(size=2)+
  geom_encircle(aes(fill = pop_year), s_shape = 0.5, expand = 0.02,
                  alpha = 0.2, show.legend = FALSE)+
  scale_x_continuous(name=plot1m.pre[["plot.args"]][["xlab"]])+
  scale_y_continuous(name=plot1m.pre[["plot.args"]][["ylab"]])+
  scale_colour_manual(name="Group", values = mypalette)+
theme(axis.title.x = element_text(size=title.size, colour = 'black'),
        axis.title.y = element_text(size=title.size, color = 'black'),
        axis.text.x = element_text(size=text.size, colour = 'black'),
        axis.text.y = element_text(size=text.size, colour = 'black'),
        axis.line=element_line(colour='black', size=line.size),
        panel.grid.major = element_line(),
        panel.border = element_rect(fill = NA),
        panel.background = element_blank())+
  coord_fixed(ratio = diff(xlim)/diff(ylim), xlim=xlim, ylim=ylim, expand=F)

Thank you so much in advance.

example