R 如何将方框图上的点替换为点';对应的行号索引是什么?
我有一个如下所示的数据框:R 如何将方框图上的点替换为点';对应的行号索引是什么?,r,ggplot2,boxplot,R,Ggplot2,Boxplot,我有一个如下所示的数据框: Train_Table_Time_Power <- data.frame( Skew = runif(250), Crest = runif(250), Kurt = runif(250), Impulse = runif(250), TI = sample(c("0.05", "0.10", "0.15", "0.20"), 10, replace = TRUE) ) Tra
Train_Table_Time_Power <- data.frame(
Skew = runif(250),
Crest = runif(250),
Kurt = runif(250),
Impulse = runif(250),
TI = sample(c("0.05", "0.10", "0.15", "0.20"), 10, replace = TRUE)
)
Train\u Table\u Time\u Power只需使用geom\u text()
而不是geom\u jitter()
,但请注意,由于标签重叠,可读性受到限制
# add the row number as column
library(tibble)
Train_Table_Time_Power <- rowid_to_column(Train_Table_Time_Power)
ggplot(Train_Table_Time_Power, aes(x = TI, y = Crest, color = TI, label = rowid)) +
geom_boxplot(notch = T, id=TRUE) +
stat_summary(fun = mean, geom="point", shape=19, color="red", size=2) +
geom_text(position = position_jitter(0.2)) +
labs(title = "Crest_Time", x = "TI", y = "Normalized Magnitude") +
theme_minimal()
#将行号添加为列
图书馆(tibble)
列车表时间功率
# add the row number as column
library(tibble)
Train_Table_Time_Power <- rowid_to_column(Train_Table_Time_Power)
ggplot(Train_Table_Time_Power, aes(x = TI, y = Crest, color = TI, label = rowid)) +
geom_boxplot(notch = T, id=TRUE) +
stat_summary(fun = mean, geom="point", shape=19, color="red", size=2) +
geom_text(position = position_jitter(0.2)) +
labs(title = "Crest_Time", x = "TI", y = "Normalized Magnitude") +
theme_minimal()