我正在尝试用2个变量制作密度图,但我需要更粗的线条。我使用过这个命令:
>print(plot(density(x,na.rm = T),col="blue",lwd=3,main="Text",cex.main=1.2))
>lines(density(y,na.rm = T),col="purple",lwd=3)
虽然它确实使该行变粗,但在命令下方显示:NULL
我究竟做错了什么?提前谢谢。
1 个答案:
答案 0 :(得分:0)
无需print
。只是做:
# Sample data
set.seed(2017);
x <- rnorm(100, 2);
y <- rnorm(100, 2, 3);
plot(density(x, na.rm = T), col = "blue", lwd = 3, main = "Text", cex.main = 1.2);
lines(density(y, na.rm = T), col = "purple", lwd = 3)