You can fix this by explicitly specifying the line type ( lty
argument), for example:
plot(c(0,1), c(0, 1), type = "n") legend("topleft", legend = c("Model", "Data"), lwd = c(3, NA), lty = c(1, 0),
EDIT
The documentation for the lwd
argument, in ?par
explains that:
'lwd' Line width, positive number, default is '1'. the interpretation is device-specific, and some devices do not use line widths less than one.
The default Mac graphics device R should be one of them. (FWIW, with your code, my own Windows graphics device shows a line through the data point, as in pdf.)
In any case, it is generally safer to use lty
than lwd
to manage this particular part.
source share