英文:
creating labels in parallel coordinates plot with R, ggparcoord()
问题
我想在平行坐标图的每行左侧只显示一次标签。我只能在每个实例上获得标签,所以看起来不清晰。
## 测试数据集
data2 <- data.frame(
"geneSymbol" = paste("Gene", 1:10),
"condition1" = rnorm(10, 3, 1),
"condition2" = rnorm(10, 4, 0.5),
"condition3" = rnorm(10, 7, 0.3)
)
# 使用GGally中的ggparcoord()构建平行坐标图
ggparcoord(data= data2,
columns = 2:4,
groupColumn = 1,
scale = "std",
scaleSummary = "mean",
centerObsID = 1,
missing = "exclude",
showPoints = FALSE,
splineFactor = FALSE,
alphaLines = 1,
boxplot = TRUE,
shadeBox = NULL,
mapping = NULL,
title = "TEST")+
geom_text(aes(label=geneSymbol))
有人有什么想法吗?
最好的祝福
wbart
英文:
I want to have labels only one time on the left of each line in a parallel coordinates plot. I only managed to get labels on every instances so it doesn't look clear.
## test data set
data2 <- data.frame(
"geneSymbol" = paste("Gene", 1:10),
"condition1" = rnorm(10, 3, 1),
"condition2" = rnorm(10, 4, 0.5),
"condition3" = rnorm(10, 7, 0.3)
)
#building parallel coordination plot with ggparcoord() from GGally
ggparcoord(data= data2,
columns = 2:4,
groupColumn = 1,
scale = "std",
scaleSummary = "mean",
centerObsID = 1,
missing = "exclude",
showPoints = FALSE,
splineFactor = FALSE,
alphaLines = 1,
boxplot = TRUE,
shadeBox = NULL,
mapping = NULL,
title = "TEST")+
geom_text(aes(label=geneSymbol))
Does anyone has an idea?
Best regards
wbart
答案1
得分: 0
你可以使用ifelse
函数使标签依赖于x轴的值。
ggparcoord(data = data2,
columns = 2:4,
groupColumn = 1,
scale = "std",
scaleSummary = "mean",
centerObsID = 1,
missing = "exclude",
showPoints = FALSE,
splineFactor = FALSE,
alphaLines = 1,
boxplot = TRUE,
shadeBox = NULL,
mapping = NULL,
title = "TEST") +
geom_text(aes(label = ifelse(variable == "condition1",
as.character(geneSymbol), "")), hjust = 1.2)
英文:
You can make the labels dependent on the x axis value using ifelse
ggparcoord(data= data2,
columns = 2:4,
groupColumn = 1,
scale = "std",
scaleSummary = "mean",
centerObsID = 1,
missing = "exclude",
showPoints = FALSE,
splineFactor = FALSE,
alphaLines = 1,
boxplot = TRUE,
shadeBox = NULL,
mapping = NULL,
title = "TEST") +
geom_text(aes(label = ifelse(variable == "condition1",
as.character(geneSymbol), "")), hjust = 1.2)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论