Why does plot not respect add = TRUE?
r
Solution
Because `plot.default` doesn't have an `add` argument
> args(plot.default)
function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first = NULL,
panel.last = NULL, asp = NA, ...)
NULL
Those other functions are not overriding `plot` but are providing their own methods, which do have an argument `add` because they were written that way. Personally, having grown up with using `points()` and `lines()` etc I don't find them much extra work and I would use them in preference to a `plot` method with an `add` argument, although we've written both ways in packages that I contribute to.
As to why `plot.default` doesn't have an `add` argument? You'd have to ask R Core, but I can suggest some reasons
- `plot.default` is designed to generate an entire plot on the device
- There already are `points()` and `lines()` etc so why duplicate?
- `plot.default` is simpler code without code to handle `add`
- Backwards compatibility with S/S-Plus
Problem
Why does R's base plot function do this? We have to use `points` or `lines`, which needs special code rather than using the `type` argument. ``` plot(1:10) plot(10:1, add = TRUE) Warning messages: 1: In plot.window(...) : "add" is not a graphical parameter 2: In plot.xy(xy, type, ...) : "add" is not a graphical parameter 3: In axis(side = side, at = at, labels = labels, ...) : ``` Etc. Many packages provide methods for (i.e. "override") plot and provide the obvious ability to plot(obj, add = TRUE) as long as `obj` is of the appropriate class. (Examples are `sp`, `raster`, `spatstat`.) Is there any reason `plot.default` does not already? EDIT: this was discussed at length here: https://stat.ethz.ch/pipermail/r-devel/2008-March/048628.html DM effectively answers it here: https://stat.ethz.ch/pipermail/r-devel/2008-March/048650.html