【发布时间】:2021-08-23 05:29:27
【问题描述】:
我想使用par(new = TRUE) 来绘制我的绘图,这些绘图是在另一个循环中生成的。
但是我如何确保每个新情节都有另一种颜色?
现在全是黑色的,被覆盖了,所以我已经无法区分这些情节了:
for(i in names(extensor_raw[2:9])){
# Coerce a data.frame into an 'emg' object
x <- as.emg(extensor_raw[i], samplingrate = 1000, units = "mV") ##do this for every channel
# Compute the rectified signal
x_rect <- rectification(x)
# Filter the rectified signal
y <- lowpass(x_rect, cutoff = 100)
# plot the original channel, the filtered channel and the LE-envelope
plot(y, main = paste("LE-envelope"))
par(new = TRUE)
}
我尝试实现以下内容:我尝试包含col = rainbow(9)[i],但这只会给我一个空白图:
plot(y, main = paste("LE-envelope") , col=rainbow(9)[i])
par(new = TRUE)
根据 cmets 的要求,我使用了dput(y)(不确定位置是否正确:
for(i in names(extensor_raw[2:9])){
# Coerce a data.frame into an 'emg' object
x <- as.emg(extensor_raw[i], samplingrate = 1000, units = "mV") ##do this for every channel
# Compute the rectified signal
x_rect <- rectification(x)
# Filter the rectified signal
y <- lowpass(x_rect, cutoff = 50)
# plot the original channel, the filtered channel and the
# LE-envelope
plot(y, main = paste("LE-envelope extensor") , col=rainbow(9)[i])
par(new=T)
}
dput(y)
结果如下:
- 仍有空地
【问题讨论】:
标签: r loops plot multiple-columns