data-edu / tidyLPA

Easily carry out Latent Profile Analysis (LPA) using open-source or commercial software
https://data-edu.github.io/tidyLPA/
Other
55 stars 15 forks source link

Changing legend names and colors #193

Closed teindor closed 2 years ago

teindor commented 2 years ago

Hi, I tried to change the legend values and colors (instead of just using the number of groups). I used this code:

plot_profiles(results$model_1_class_6, add_line = T, rawdata = T, sd = F) + ggplot2::scale_color_manual(labels= c("Problematic users", "2","3","4","5","6"), values = c("#0444BF","#0584F2","#0AAFF1", "#EDF259","#A79674","#6465A5")) +ggplot2::xlab("Measures")+ ggplot2::ylab("Addiction score")+ggplot2::scale_x_continuous(breaks = c(1:6), labels = c("add_prob_ch"="Problemetic use baseline", "add_emo_ch"="Emotional gain baseline", "add_envi_ch"="Socio-environmental baseline", "add_prob_ch_t2"="Problemetic use 6mo", "add_emo_ch_t2"="Emotional gain 6mo", "add_envi_ch_2"="Socio-environmental 6mo"))

It works, but the original set of legend is also present 43094134-3e3a-47f3-a350-31045d8e72cf

Suggestions?

cjvanlissa commented 2 years ago

@teindor , with all respect, these are all ggplot2 questions. I'd recommend reading their manual or searching stackexchange!

teindor commented 2 years ago

True. It is the way ggplot2 interacts with the plot_profiles, and I couldn't figure the answer because it is not a native ggplot plot that I can assign "aes". Thank for your previous assistance

cjvanlissa commented 2 years ago

Just google gglplot hide legend and you'll find it. I google this every time I do it..