I’m trying to set xlim and ylim in ggplot put using the below:
ylim=c(0, 1.5) +
xlim=c(0,100) +
OR
coord_cartesian(xlim = c(0, 100), ylim = (0,1.5)) +
Seems to throw this error:
Error in scale_x_discrete(breaks = c(0, 50, 100), labels = c(0, :
non-numeric argument to binary operator
Is this because I’m using a discrete scale for x? I am using a numeric for y.
Using
scale_y_continuous(limits = c(0, 1.5)) +
seems to work but gives the error:
Warning message:
Removed 2 rows containing missing values (geom_path).
Any suggestions on what I can try?
Full code:
cfr <- ggplot(sn, aes(x = mmad,y = fr, group=Plan, colour = Plan)) +
geom_line(size=0.5) +
scale_x_discrete(breaks = c(0,50,100), labels= c(0,50,100)) +
labs(x = "mmad",y = "%")
P.S.
Without putting the axis limits in, the above code worked without a problem
Read more here: Source link