saving . . . saved outcome is different by typing command. has been deleted. outcome is different by typing command. has been hidden .
outcome is different by typing command.
Title
Question
when we make 2 graphs in one plot, the 2 plots sin and cos with their name appears;  but I can only see sin name without cos name even after typing correct command. My plot names are not completely visible.

R Introduction-to-ggplot2 06-07 min 50-60 sec 03-05-20, 10:08 p.m. gaurvanvita.singh01@gmail.com

Answers:

Could you please share the exact command which you are talking about? 
04-05-20, 5:58 p.m. sudhakarst
legend("topleft",

c("sin(x)", "cos(x)"),

fill=c("blue","red"))

04-05-20, 11:10 p.m. gaurvanvita.singh01@gmail.com
-------------------------------------------------------------------------
x <- seq(-pi, pi, 0.1)
plot(x, sin(x),
     main = "Two graphs in one plot",
     ylab = "",
     type = "l",
     col = "blue")
lines(x, cos(x),
      col = "red")
legend("topleft",
       c("sin(x)","cos(x)"),
       fill = c("blue","red"))
--------------------------------------------------------------------------
Please make sure that you are typing the commands as shown above. 

04-05-20, 11:16 p.m. sudhakarst
x <- seq(-pi, pi, 0.1)

y <- sin(x)

plot(x, y)
plot(x, y, main="Plotting a Sine Curve", ylab="sin(x)")
plot(x, y, main="Plotting sine curve", ylab="sin(x)", type="l", col="blue")
plot(x, sin(x), main="Plotting Sine and Cosine graphs on the same plot",
    
     ylab=" ", type="l", col="blue")

lines(x, cos(x), col="red")
legend("topleft",
      
       c("sin(x)", "cos(x)"),
      
       fill=c("blue","red"))

In the second argument the name cos(x) is not printed on graph. Also sin(x)  overlapping the lines of graph.
04-05-20, 11:17 p.m. gaurvanvita.singh01@gmail.com

Login to add comment


Try increase area of plots window (say to 75%) in RStudio
28-11-20, 2:52 p.m. satishvermadu@gmail.com


Log-in to answer to this question.