在R中是否有一种简单的方法可以使绘图的所有元素(轴,轴标签,网格线,刻度线......)变成白色并带有黑色背景?我已经看到了制作黑色背景的一些选项,但我不知道如何重新着色情节元素。
我希望在相对复杂的情节中这样做。我的绘图与使用虹膜数据集的scatter3D示例here under "Change color by groups"非常相似。我已经包含了必要的代码来复制下面的情节。
library(plot3D)
# Set up data
data(iris)
x <- sep.l <- iris$Sepal.Length
y <- pet.l <- iris$Petal.Length
z <- sep.w <- iris$Sepal.Width
# Make 3d scatterplot with colors by category
scatter3D(x, y, z, bty = "g", pch = 18,
col.var = as.integer(iris$Species),
col = c("#1B9E77", "#D95F02", "#7570B3"),
pch = 18, ticktype = "detailed",
colkey = list(at = c(2, 3, 4), side = 1,
addlines = TRUE, length = 0.5, width = 0.5,
labels = c("setosa", "versicolor", "virginica")) )
答案 0 :(得分:2)
par(bg = 'black', fg = 'white') # set background to black, foreground white
scatter3D(
x,
y,
z,
bty = "u", ## 'u' seemed to look better than 'g'
pch = 18,
col.var = as.integer(iris$Species),
col = c("#1B9E77", "#D95F02", "#7570B3"),
pch = 18,
ticktype = "detailed",
colkey = list(
at = c(2, 3, 4),
side = 1,
addlines = TRUE,
length = 0.5,
width = 0.5,
labels = c("setosa", "versicolor", "virginica"),
col.axis = "white",
col.clab = "white"
),
col.axis = "white",
col.panel = "black",
col.grid = "white"
)
我刚刚浏览了?scatter3D
中的参数列表,并将大多数颜色设置为白色 - 您可能可以去掉其中一些设置(或找到您想要添加的更多设置)。例如,我没有检查主要调用和col.axis = 'white'
列表中是否需要colkey
。还可以设置更多颜色(如col.ticks
)。我建议在帮助页面搜索“col”。