Reputation: 467
Is there an R package allowing to plot parallel coordinates with confidence intervals? Like the example below.
Or what would be the easiest alternative? Making multiple ggplots and printing them side by side with ggarrange or 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")]
Upvotes: 0
Views: 297
Reputation: 155
There are two libraries that let you plot parallel coordinate charts.
I believe ggparci would be best fit for you question. 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
ggparcoord(df, columns=1:10, groupColum = 5)
GGally has scale option for further processing of the plot.
I plotted df without any processing and it looks like :
And in MASS library there is a function called parcoord()
Example use:
# MASS library
library(MASS)
# Color
color <- colors()[as.numeric(iris$Species)*11]
# Plot
parcoord(iris[,c(1:4)] , col= color)
Upvotes: 1