Ina
January 23, 2019, 12:43pm
1
I'm sorry, it's because I'm a beginner in R's and I still need help with more basic things.
How could I color each genus with different colors of the y-axis variables? Thanks for the help.
This is my graph:
I used this code:
>data<-read.csv("prof-2col-r.csv",sep=";")
>data
>data$Espécie <- factor(data$Espécie, levels = c("Mycteroperca tigris","Paralabrax nebulifer","Mycteroperca xenarcha","Mycteroperca prionura","Mycteroperca jordani","Epinephelus guttatus","Mycteroperca olfax","Mycteroperca venenosa","Mycteroperca bonaci","Dermatolepis dermatolepis","Alphestes afer","Paralabrax clathratus","Epinephelus striatus","Paranthias colonus","Mycteroperca rosacea","Epinephelus polyphekadion","Epinephelus ongus","Epinephelus marginatus","Epinephelus itajara","Epinephelus fuscoguttatus","Plectropomus maculatus","Plectropomus leopardus","Plectropomus areolatus"))
>ggplot(data, aes(x = Espécie, y = Profundidade)) +
geom_boxplot(outlier.colour="red", outlier.shape=8,
outlier.size=2, notch=FALSE) + coord_flip() + theme_classic() + labs(title = "Epinephelidae", x = "Espécies", y = "Profundidade")
It's not clear what you mean by " colors of the y-axis variables" but if you are trying to change the color of the boxes by especies, then add the fill
aesthetic.
ggplot(data, aes(x = Espécie, y = Profundidades, fill = Espécie)) +
1 Like
Ina
January 23, 2019, 3:06pm
3
in fact I created another column in the worksheet (gender) and I put fill = gender and it worked. Thanks
This would be hard to guess since you haven't provided sample data, the next time please make a reproducible example.
Why reprex?
Getting unstuck is hard. Your first step here is usually to create a reprex, or reproducible example. The goal of a reprex is to package your code, and information about your problem so that others can run it and feel your pain. Then, hopefully, folks can more easily provide a solution.
What's in a Reproducible Example?
Parts of a reproducible example:
background information - Describe what you are trying to do. What have you already done?
complete set up - include any library() calls and data to reproduce your issue.
data for a reprex: Here's a discussion on setting up data for a reprex
make it run - include the minimal code required to reproduce your error on the data…
system
Closed
January 30, 2019, 3:09pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.