data-visualization

Violinplot in R with discrete values

好久不见. 提交于 2021-02-07 20:52:31
问题 I'm trying to create a violin plot in R from count data. The data I use is a number of mutations that is found in each sample for each source. It looks something like this: 2 Source1 8 Source2 0 Source1 1 Source1 9 Source2 ... I already used the code below to create several plots. ggplot(df_combined, aes(factor(names), y=mutations)) + geom_violin() + geom_boxplot(width=.1, outlier.size=0, fill="grey50") + stat_summary(fun.y=median, geom="point", fill="white", shape=21, size=4) + xlab("Source"

Violinplot in R with discrete values

拟墨画扇 提交于 2021-02-07 20:48:42
问题 I'm trying to create a violin plot in R from count data. The data I use is a number of mutations that is found in each sample for each source. It looks something like this: 2 Source1 8 Source2 0 Source1 1 Source1 9 Source2 ... I already used the code below to create several plots. ggplot(df_combined, aes(factor(names), y=mutations)) + geom_violin() + geom_boxplot(width=.1, outlier.size=0, fill="grey50") + stat_summary(fun.y=median, geom="point", fill="white", shape=21, size=4) + xlab("Source"

Seaborn: Making barplot by group with asymmetrical custom error bars

北城以北 提交于 2021-02-07 04:01:51
问题 I have a Pandas dataframe that has a couple of group columns like below. gr1 grp2 variables lb m ub A A1 V1 1.00 1.50 2.5 A A2 V2 1.50 2.50 3.5 B A1 V1 3.50 14.50 30.5 B A2 V2 0.25 0.75 1.0 I am trying to get a separate sub-barplot for each variable in variables using FacetGrid . I am trying to build to the final plot that I need which looks like the below. This is what I have so far. g = sns.FacetGrid(df, col="variables", hue="grp1") g.map(sns.barplot, 'grp2', 'm', order=times) But

R: Plot not Fully Loading

…衆ロ難τιáo~ 提交于 2021-02-05 10:49:07
问题 I am working the R programming language. I am trying to follow this tutorial over here: https://plotly.com/r/parallel-coordinates-plot/ I am trying to make a "parallel coordinate plot" of the famous iris data set. Instead of loading the iris data set through the github link, I tried to use the built in iris data set that is available in R: #load library library(plotly) #load data data(iris) df = iris #make plot fig <- df %>% plot_ly(type = 'parcoords', line = list(color = ~Species, colorscale

R: Plot not Fully Loading

核能气质少年 提交于 2021-02-05 10:49:01
问题 I am working the R programming language. I am trying to follow this tutorial over here: https://plotly.com/r/parallel-coordinates-plot/ I am trying to make a "parallel coordinate plot" of the famous iris data set. Instead of loading the iris data set through the github link, I tried to use the built in iris data set that is available in R: #load library library(plotly) #load data data(iris) df = iris #make plot fig <- df %>% plot_ly(type = 'parcoords', line = list(color = ~Species, colorscale

R: adding axis titles to non ggplot objects

*爱你&永不变心* 提交于 2021-02-05 09:25:07
问题 I am working with the R programming language. Normally when I make plots, I am using the ggplot2 library and the aes() options can be used to label the x-axis and add a title. However this time, I the plots I am making are not ggplot2 objects, and therefore can not be labelled in the same way: library(MASS) library(plotly) a = rnorm(100, 10, 10) b = rnorm(100, 10, 5) c = rnorm(100, 5, 10) d = matrix(a, b, c) parcoord(d[, c(3, 1, 2)], col = 1 + (0:149) %/% 50) #error - this is also apparent

R: by group mirrored histogram using ggplot2

五迷三道 提交于 2021-02-05 08:27:10
问题 I would like to get a mirrored histogram by group using ggplot as illustrated in the picture at the bottom. library(ggplot2) data2 <- data.frame( type = c( rep("Top 1", n_segment), rep("Top 2", n_segment), rep("Bottom 1", n_segment), rep("Bottom 2", n_segment)), value = c( rnorm(n_segment, mean=5), rnorm(n_segment, mean=12), rnorm(n_segment, mean=-5), rnorm(n_segment, mean=-12)) ) # Represent it data2 %>% ggplot( aes(x=value, fill=type)) + geom_density( color="#e9ecef", alpha=0.6) For now I

R: Parallel Coordinates Plot without GGally

倖福魔咒の 提交于 2021-02-05 08:09:56
问题 I am using the R programming language. I am using a computer that does not have a USB port or an internet connection - I only have R with a few preloaded libraries (e.g. ggplot2, reshape2, dplyr, base R). Is it possible to make "parallel coordinate" plots (e.g. below) using only the "ggplot2" library and not "ggally"? #load libraries (I do not have GGally) library(GGally) #load data (I have MASS) data(crabs, package = "MASS") #make 2 different parallel coordinate plots ggparcoord(crabs)

R: Plot Axis Display Values Larger than the Original Data

限于喜欢 提交于 2021-02-04 08:27:07
问题 I am using the R programming language. I am following a tutorial on data visualization over here: https://plotly.com/r/3d-surface-plots/ I created my own data and made a 3D plot: library(plotly) set.seed(123) #generate data a = rnorm(100,10,10) b = rnorm(100,5,5) c = rnorm(100,5,10) d = data.frame(a,b,c) #3d plot fig <- plot_ly(z = ~as.matrix(d)) fig <- fig %>% add_surface() #view plot fig As seen here, there is a point on this 3D plot where "y = 97". I am not sure how this is possible,

R: arranging multiple plots together using gridExtra

 ̄綄美尐妖づ 提交于 2021-02-02 09:59:07
问题 I am using the R programming language. I am trying to arrange "plot1, plot2, plot3, plot4" on the same page: library(kohonen) #fitting SOMs library(ggplot2) #plots library(GGally) #plots library(RColorBrewer) #colors, using predefined palettes iris_complete <-iris[complete.cases(iris),] #only complete cases... the iris dataset floats around in the sky with diamonds. iris_unique <- unique(iris_complete) # Remove duplicates #scale data iris.sc = scale(iris_unique[, 1:4]) #build grid iris.grid =