in Education by
How can I plot two graphs in same plot in R, I am using this command to perform my task but it isn’t working. x <- seq(-3, 4, 1.05) y1 <- pnorm(x) y2 <- pnorm(x, 2, 2) plot(x, y1, type = "2", col = "blue") plot(x, y2, type = "l", col = "yellow") Please help me with it. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
There are several methods to perform this task I am sharing a few with you: Method-1: Use par, it will plot on the same graph but axis will be different. E.x. plot( x, y1, type="l", col="blue" ) par(new=TRUE) plot( x, y2, type="l", col="yellow" ) Method-2: You can add lines() or points() to the existing graph but it won’t create a new window. plot(x,y1,type="l",col="blue") lines(x,y2,col="yellow") Method-3: Use matplot function, e.x. matplot(x, cbind(y1,y2),type="l",col=c("blue","yellow"),lty=c(1,1)) There are some other methods too, I hope one of this help you with your issue.

Related questions

0 votes
    I am ploating simple linear regression plot in R and I want to save it as JPEG or PNG file, How can I do ... it is, Is it possible? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    _________ describe the type of plot you will produce. (a) geoms (b) ggplot (c) fplot (d) gplot This ... Data Analysis of R Programming Select the correct answer from above options...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    A very newbish question, but say I have data like this: test_data...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Hi this simple code (and all my scripts from this morning) has started giving me an off-center title in ggplot2 Ubuntu ... the above this morning to try and fix this.... dat...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Can someone tell me any methods change the size of figures drawn with matploatlib? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Suppose I have a ggplot with more than one legend. mov...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm trying to keep the legend of one layer (smooth) and remove the legend of the other (point). I have tried ... = gear)) + theme_bw() Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have used the following ggplot command: ggplot(survey, aes(x = age)) + stat_bin(aes(n = nrow(h3), y = ... but cannot figure out how. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    ________ function can be used to add datasets in R provided with the columns in the datasets should be the same ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Which is the basic data structure of R containing the same type of data? (a) Functions (b) Array (c) ... and Out of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What is the role of exploratory graphs in data analysis? (a) They are made for formal presentations (b) ... Analysis of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I want the first subplot to only include 'Máximo', 'Média', 'Mínimo', and the second to only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I create a plot_ly image using: MilesPlotly...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I create a plot_ly image using: MilesPlotly...
asked Jul 6, 2022 in Education by JackTerrance
...