R - How to Plot Multiple Density Plots With ggvis -


how 1 go plotting multiple density plots on same set of axes? understand how plot multiple line graphs , scatter plots together, matter of having density plots share common x-axis tripping me up. data set such:

name  x1   x2   x3     123  123  123 b     123  123  123 c     123  123  123 

thanks help!

edit: here details missing may make question clearer.

i have data frame attr_gains looks example above, , variable names str, agi, , int. far, have been able density plot of str variable alone code:

  attr_gains %>%   ggvis(x=~str)%>%   layer_densities(fill :="red", stroke := "red") 

what overlay 2 more density plots, 1 agi , int each, have 3 density plots on same set of axes.

directly documentation:

plantgrowth %>%    ggvis(~weight, fill = ~group) %>%    group_by(group) %>%   layer_densities() 

link

your case:

set.seed(1000) library('ggvis') library('reshape2')  #############################################  df = data.frame(matrix(nrow = 3, ncol = 5)) colnames(df) <- c('names', 'x1', 'x2', 'x3', 'colors')  df['names'] <- c('a','b','c')     df['x1'] <- runif(3, 100.0, 150.0) df['x2'] <- runif(3, 100.0, 150.0) df['x3'] <- runif(3, 100.0, 150.0) df['colors'] <- c("blue","orange","green")  df <- melt(df)  #############################################  df %>%    ggvis( ~value, fill = ~colors ) %>%    group_by(names) %>%   layer_densities() 

please see this se page information on controlling ggvis color(s).


looks this:

density plot


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -