I created a normal distribution plot which actually works as I want. I tried to add a point but it fails to load it even if I got zero errors
typed this:
k<-0
z <- 25440
plot(x,y) + points(k,z,pch=19,col="blue",cex=5)
which gives me an output of
integer(0)
and my plot loaded without adding my desired point.
Does anyone have any idea how to handle it?
Thanks in advance
There are two things that need to be pointed out here:
There is no need to use the + sign (that's for ggplot). You should just add the points() function below the plot as it will add to it automatically (that's what's generating the integer(0))
In the base R plot, the canvas of the plot is decided when the plot function is used first based on the initial data (or specific arguments specified). All data added later that falls out of the initial canvas will not be visible as the canvas does not resize based on new data
Here is an example that works:
k<-5
z <- 0.5
plot(1:10, runif(10))
points(k,z,pch=19,col="blue",cex=5)
Here is one that won't show the blue dot as it falls outside the initial canvas
k<-5
z <- 5
plot(1:10, runif(10))
points(k,z,pch=19,col="blue",cex=5)