如何将ggparcoord的Y轴刻度设置为(1,10,100,1000)?
解决ggparcoord设置Y轴自定义刻度的问题
要将Y轴刻度设置为(1,10,100,1000),你可以在生成的图表对象后添加scale_y_continuous()函数,手动指定刻度点和标签:
p <- ggparcoord(dt1, columns = c(108,111), groupColumn = 155, order = "anyClass", scale = "globalminmax", showPoints = TRUE, alphaLines = 0.3) + scale_y_continuous(breaks = c(1, 10, 100, 1000), labels = c("1", "10", "100", "1000"))
补充说明
breaks参数用于定义Y轴上要显示的刻度位置labels参数对应刻度的显示文本(这里和刻度值一致,可按需调整格式)- 如果你的数据范围超出1-1000,可添加
limits = c(1, 1000)来限定Y轴范围,确保所有目标刻度都能正常显示:
p <- ggparcoord(dt1, columns = c(108,111), groupColumn = 155, order = "anyClass", scale = "globalminmax", showPoints = TRUE, alphaLines = 0.3) + scale_y_continuous(breaks = c(1, 10, 100, 1000), labels = c("1", "10", "100", "1000"), limits = c(1, 1000))
内容的提问来源于stack exchange,提问作者Sajin Kang
相关产品推荐
相关产品推荐

