I am working with timeseries with millions of points. I normally plot this data with
plot(x,type='l')
Things slow down terribly if I accidentally type
plot(x)
because the default is type='p'
Is there any way using setHook()
or something else to modify the default plot(type=...)
during an R session?
I see from How to set a color by default in R for all plot.default, plot or lines calls that this can be done for par()
parameters like 'col'. But there doesn't appear to be any points-vs-line setting in par()
.
A lightweight solution is to just define a wrapper function that calls plot()
with type="l"
and any other arguments you've given it. This approach has some possible advantages over changing an existing function's defaults, a few of them mentioned here
lplot <- function(...) plot(..., type="l")
x <- rnorm(9)
par(mfcol=c(1,2))
plot(x, col="red", main="plot(x)")
lplot(x, col="red", main="lplot(x)")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With