I am trying to build a custom function to add points to a plot window. My problem is that when I use jitter
it seems that the spread is different in the right vs left part of the plot.
Why is this ?
set.seed(8)
f1 <- function(x, y, col = 'black', xjit = 5, ...) {
points(x = jitter(rep(x, length(y)), xjit), y = y, col = col, ...)
}
v <- sample(1:1000, 1000, T) #Some data to plot
ymax <- max(v)
plot.new() #Build a canvas from scratch
plot.window( xlim = c(1, 10), ylim = c(0, ymax) )
ticks <- seq(1, 10, 1)
axis(1, at=ticks, labels=NA)
axis(2)
#Plot the same data to the left (x=1) and right (x=10)
f1(1, v, 'red', pch = 4)
f1(10, v, 'blue', pch = 4)