Home > other >  Merging two different Plots in R
Merging two different Plots in R

Time:04-07

I want to merge two plot in only one graph in R ,but i stuck how to accomplish it

First plot :

     plot_1 <- plot(serie_2,dt_frame$students,main="Plot 1",col=1,pch=19)

Second Plot :

      plot_2 <- plot(serie_3,dt_frame$numbers,main="Plot 2",col=5,pch=19)

How can i show these separate plots in one plot

CodePudding user response:

You could use ggplot2:

library(ggplot2)

ggplot()  
 geom_point(aes(x=serie_2, y=dt_frame$students, col="blue"))  
 geom_point(aes(x=serie_3, y=dt_frame$numbers, col="red"))  
 labs(x = "Student", y = "Grade")  
 scale_color_manual(values=c("blue", "red"),
                    labels=c("Series 2", "Series 3"))

  • Related