[英]Plotting parallel coordinates with confidence intervals in R
Is there an R package allowing to plot parallel coordinates with confidence intervals?是否有 R 包允许绘制具有置信区间的平行坐标? Like the example below.
就像下面的例子。
Or what would be the easiest alternative?或者什么是最简单的选择? Making multiple ggplots and printing them side by side with ggarrange or patchwork?
制作多个ggplots并与ggarrange或patchwork并排打印?
Generated data生成的数据
library(tidyverse)
set.seed(1)
#make new data
df = tibble(
factor= c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O"),
var1 = rnorm(15, 50, 20),
var2 = rnorm(15, 10, 4),
var3 = rnorm(15, 2, 1))
#add confidence intervals
df = df %>% mutate(
var1_lower = var1 - runif(1, 5, 15),
var1_upper = var1 + runif(1, 5, 15),
var2_lower = var2 - runif(1, 0.5, 2.2),
var2_upper = var2 + runif(1, 0.5, 2.2),
var3_lower = var3 - runif(1, 0.1, 0.6),
var3_upper = var3 + runif(1, 0.1, 0.6))
#reorder columns
df = df[c("factor", "var1", "var1_lower", "var1_upper", "var2", "var2_lower", "var2_upper", "var3", "var3_lower", "var3_upper")]
There are two libraries that let you plot parallel coordinate charts.有两个库可让您绘制平行坐标图。
I believe ggparci would be best fit for you question.我相信 ggparci 最适合您的问题。 As it allows you to plot confidence interval with the data.
因为它允许您用数据绘制置信区间。 I have given the link to the library documentation in the comment above.
我在上面的评论中给出了图书馆文档的链接。
But, I am mentioning rest two for the benefit of everyone.但是,我提到休息二是为了每个人的利益。
In GGally library you can use在 GGally 库中,您可以使用
ggparcoord(df, columns=1:10, groupColum = 5)
GGally has scale option for further processing of the plot. GGally 具有用于进一步处理绘图的比例选项。
I plotted df without any processing and it looks like :我在没有任何处理的情况下绘制了 df ,它看起来像:
And in MASS library there is a function called parcoord()
在 MASS 库中有一个名为
parcoord()
的函数
Example use:使用示例:
# MASS library
library(MASS)
# Color
color <- colors()[as.numeric(iris$Species)*11]
# Plot
parcoord(iris[,c(1:4)] , col= color)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.