Entering edit mode
6.2 years ago
erick_rc93
▴
30
I have merged two data.frames with the same column names but different number and name of rownames in R, and I have made a scatter plot in ggplot, but I'd like two have two different colour of dots in the plot
model_3 <- rbind(df_1,df_2)
plot <- ggplot(data=model_3, aes(x=model_3[,"log(obs/exp)"], y=model_3[,"log(obs-exp)^2/exp)"],colour = model_3[,"log(obs/exp)"]))+geom_point()+
geom_text(label=rownames(model_3), hjust = 0, nudge_x = 0.05, size = 1.5) +
labs(colour = "log(obs/esp)",size = 0.5) +
labs(x = "log(obs/esp)") +
labs(y="log(obs-exp)^2/exp)") +
ggtitle("random-name"))+
xlim(-11, 16)+ylim(-11,16) +
theme(panel.background = element_rect(fill = "white", colour = "grey50"))
above I show the code that I'm using, but this only adds color according to the values of a column, but I want them to be colored with respect to the names of each dataframe that was merged.
Can you show
head(df1
) &head(df2)
?Seems like you can add add one more column to each
data.frame
e.g.Then color based on
SOURCE