【发布时间】:2020-03-23 21:05:26
【问题描述】:
我需要在下面的代码中包含一条垂直线, 例如,在位置 x = 5 并且所有小于 5 的点都有另一种颜色, 例如蓝色。
可以从 x 轴读取变量的值,y 轴显示变量中观察值的顺序(从下到上)。作为远端的孤立点,在情节的两侧,表明潜在的异常值
谢谢
library(dplyr)
library(lattice)
n = 1000
df <- tibble(
xx1 = runif(n, min = 3, max = 10),
xx2 = runif(n, min = 3, max = 10),
xx3 = runif(n, min = 3, max = 10)
)
MyVar <- c("xx1","xx2","xx3")
MydotplotBR <- function(DataSelected){
P <- dotplot(as.matrix(as.matrix(DataSelected)),
groups=FALSE,
strip = strip.custom(bg = 'white',
par.strip.text = list(cex = 1.2)),
scales = list(x = list(relation = "same",tck = 1,
draw = TRUE, at=seq(0,10,1)),x=list(at=seq),
y = list(relation = "free", draw = FALSE),
auto.key = list(x =1)),
col=10,
axes = FALSE,
cex = 0.4, pch = 5,
xlim=c(0,10),
xlab = list(label = "Variable Value", cex = 1.5),
ylab = list(label = "Order of data in the file", cex = 1.5))
print(P)
}
(tempoi <- Sys.time())
Vertemp <- MydotplotBR(df[,MyVar])
(tempof <- Sys.time()-tempoi)
【问题讨论】:
-
您为此使用 dotplot 有什么原因吗?生成情节的方式使您无法意识到您想要什么。您想要一种取决于 x 轴的颜色吗?此代码生成的 3 个面板中的 x 轴并不相同。
-
您好,可以用其他功能。例如,如果 x 的值