I am using R version 3.6.0. I am trying to overlay 3 lines on a single plot. I have done this successfully in the past using identical code and for some reason it doesn't seem to be working. I have the following RWE:
y.l <- function(x){0.024 - 0.00004*x + 0.00001*(10-16.8764)}
y.a <- function(x){0.024 - 0.00004*x}
y.h <- function(x){0.024 - 0.00004*x + 0.00001*(20-16.8764)}
png("yplot.png")
yplot <- plot(y.l(1:800),
type="l", lty=2,
xlab="x", ylab="y", main="Getting better :/",
ylim=c(-0.025,0.025))
lines(1:800, lty=1, y.a(1:800))
lines(1:800, lty=3, y.h(1:800))
dev.off()
which produces the following plot:
For some reason it is ignoring the extra -lines()- code. Is there some obvious mistake I am overlooking after staring at a computer all day? I have done this exact same thing before and I cannot for the life of me figure it out. And yes I have expanded the y-axis to see if they were hiding above or below and they aren't.
Your 3 lines are plotted, it is because of your function that you can't see them. Here the output of your three function:
> head(y.a(1:800))
[1] 0.02396 0.02392 0.02388 0.02384 0.02380 0.02376
> head(y.h(1:800))
[1] 0.02399124 0.02395124 0.02391124 0.02387124 0.02383124 0.02379124
> head(y.l(1:800))
[1] 0.02389124 0.02385124 0.02381124 0.02377124 0.02373124 0.02369124
You can see that your three function give almost the same results, it because of your 0.00001*(10-16.8764)
that's is basically to small to modify your output.
If you zoom enough on the plot:
yplot <- plot(y.l(1:800),
type="l", lty=2,
xlab="x", ylab="y", main="Getting better :/",
ylim=c(.023,0.024),
xlim=c(0,30))
lines(1:800, lty=1, y.a(1:800))
lines(1:800, lty=3, y.h(1:800))
I think you need to change the last parameter of your function if you want to see a dramatic difference between your lines.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.