在R中绘制深色主题图

时间:2020-03-15 20:38:00

标签: r

假设我要绘制此函数f(x)= x ^ 2。我希望函数的图形是我想要的任何颜色,而其他所有颜色(除轴外)都是黑色。这有可能吗?

2 个答案:

答案 0 :(得分:1)

graphics.off()
par(bg = "black")
curve(x^2, -2, 2, col = "green", axes = FALSE, ann = FALSE)
title("my plot", xlab = "X", ylab = "X^2", col.lab = "white", col.main = "white")
box(col = "white")
axis(1, seq(-2, 2, 1), seq(-2, 2, 1), col = "white", col.axis = "white")
axis(2, seq(0, 4, 1), seq(0, 4, 1), col = "white", col.axis = "white")

答案 1 :(得分:0)

也许您可以?plot来看看如何制作。下面只是一个例子

plot(x<-seq(-5,5,0.1),
     x**2,
     main="square function",
     ylab="f(x)=x^2",
     type="l",
     col=28)

enter image description here