boxplot

ggplot boxplot - length of whiskers with logarithmic axis

♀尐吖头ヾ 提交于 2019-11-28 10:11:45
问题 I'm trying to create a horizontal boxplot with logarithmic axis using ggplot2. But, the length of whiskers are wrong. A minimal reproducible example: Some data library(ggplot2) library(reshape2) set.seed(1234) my.df <- data.frame(a = rnorm(1000,150,50), b = rnorm(1000,500,150)) my.df$a[which(my.df$a < 5)] <- 5 my.df$b[which(my.df$b < 5)] <- 5 If I plot this using base R boxplot() , everything is fine boxplot(my.df, log="x", horizontal=T) But with ggplot, my.df.long <- melt(my.df, value.name =

geom_boxplot() from ggplot2 : forcing an empty level to appear

此生再无相见时 提交于 2019-11-28 10:05:31
I can't find a way to ask ggplot2 to show an empty level in a boxplot without imputing my dataframe with actual missing values. Here is reproducible code : # fake data dftest <- expand.grid(time=1:10,measure=1:50) dftest$value <- rnorm(dim(dftest)[1],3+0.1*dftest$time,1) # and let's suppose we didn't observe anything at time 2 # doesn't work even when forcing with factor(..., levels=...) p <- ggplot(data=dftest[dftest$time!=2,],aes(x=factor(time,levels=1:10),y=value)) p + geom_boxplot() # only way seems to have at least one actual missing value in the dataframe dftest2 <- dftest dftest2

Boxplot of table using ggplot2

依然范特西╮ 提交于 2019-11-28 10:04:19
I'm trying to plot a boxplot graph with my data, using 'ggplot' in R, but I just can't do it. Can anyone help me out? The data is like the table below: Paratio ShapeIdx FracD NNDis Core -3.00 1.22 0.14 2.71 7.49 -1.80 0.96 0.16 0.00 7.04 -3.00 1.10 0.13 2.71 6.85 -1.80 0.83 0.16 0.00 6.74 -0.18 0.41 0.27 0.00 6.24 -1.66 0.12 0.11 2.37 6.19 -1.07 0.06 0.14 0.00 6.11 -0.32 0.18 0.23 0.00 5.93 -1.16 0.32 0.15 0.00 5.59 -0.94 0.14 0.15 1.96 5.44 -1.13 0.31 0.16 0.00 5.42 -1.35 0.40 0.15 0.00 5.38 -0.53 0.25 0.20 2.08 5.32 -1.96 0.36 0.12 0.00 5.27 -1.09 0.07 0.13 0.00 5.22 -1.35 0.27 0.14 0.00 5

Boxplot: colors by x value and hues differentiated by pattern

岁酱吖の 提交于 2019-11-28 09:34:13
问题 Say I have a boxplot like the one shown below: I would like to achieve a different coloring: Fri , Sat and Sun would be colored blue; Thur would be colored red I would like to differentiate hues with a pattern in the box (stripped or something) I can't find a way to do this manipulation using seaborn palette. I know I can mess with the boxes of a boxplot in matplotlib directly but seaborn gives me the axes back. How can I get the boxes in this case? 回答1: The boxes end up in the artists list

Make a boxplot without whiskers

孤者浪人 提交于 2019-11-28 09:04:35
问题 I have made box-plots for the onset values of three different groups using the box-plot function in R like so: boxplot(onset ~ group, data = pulse.dat, range = 0, col = "lightblue") However, I want to see how the data looks without the range, so I want to create a box-plot without the whiskers. I also wouldn't mind any kind of graph as long as it displays the median, 25th and 75th quartile for each of the 3 groups. Does anyone know how I can do this in R? 回答1: Under boxplot pars... d <- rnorm

Changing the outlier rule in a boxplot

风格不统一 提交于 2019-11-28 08:34:25
I have constructed some box-plots in R and have several outliers. I know that the default criteria to set outlier limits are: Q3 + 1.5*IQR Q1 - 1.5* IQR However, I would like outliers classified as values that fall outside of the boundaries: Q3 + 3*IQR Q1 - 3* IQR Is it possible to set this in R? From ?boxplot range : this determines how far the plot whiskers extend out from the box. If ‘range’ is positive, the whiskers extend to the most extreme data point which is no more than ‘range’ times the interquartile range from the box. A value of zero causes the whiskers to extend to the data

Adding points to horizontal boxplots

ぐ巨炮叔叔 提交于 2019-11-28 06:08:09
问题 I use the following code to produce multiple boxplots, ranked by the mean value of the variables: zx <- replicate (5, rnorm(50)) zx_means <- (colMeans(zx, na.rm = TRUE)) colnames (zx) <- seq_len (ncol (zx)) boxplot(zx [, order (zx_means)], horizontal = FALSE, outline = FALSE) points(zx_means [ order (zx_means)], pch = 22, col = "darkgrey", lwd = 7) (See this post for more details) When I change the code to horizontal = TRUE , I'm not able to make the points line up with the boxplots. Any

jitter if multiple outliers in ggplot2 boxplot

…衆ロ難τιáo~ 提交于 2019-11-28 05:34:48
I am trying to find a suitable display to illustrate various properties within and across school classes. For each class there is only 15-30 data points (pupils). Right now i am leaning towards a whisker-less boxplot, showing only 1.,2. and 3. quartile + datapoints more then e.g. 1 population SD +/- the sample median. This I can do. However - I need to show this graph to some teachers, in order to gauge what they like most. I'd like to compare my graph with a normal boxplot. But the normal boxplot looks the same if there is only one outlier, or e.g. 5 outliers at the same value. In this case

Adding a scatter of points to a boxplot using matplotlib

老子叫甜甜 提交于 2019-11-28 04:35:33
I have seen this wonderful boxplot in this article (Fig.2). As you can see, this is a boxplot on which are superimposed a scatter of black points: x indexes the black points (in a random order), y is the variable of interest. I would like to do something similar using Matplotlib, but I have no idea where to start. So far, the boxplots which I have found online are way less cool and look like this: Documentation of matplotlib: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.boxplot Ways to colorize boxplots: https://github.com/jbmouret/matplotlib_for_papers#colored-boxes Kyrubas

ggplot: arranging boxplots of multiple y-variables for each group of a continuous x

我与影子孤独终老i 提交于 2019-11-28 04:35:17
I would like to create boxplots of multiple variables for groups of a continuous x-variable. The boxplots should be arranged next to each other for each group of x. The data looks like this: require (ggplot2) require (plyr) library(reshape2) set.seed(1234) x <- rnorm(100) y.1 <- rnorm(100) y.2 <- rnorm(100) y.3 <- rnorm(100) y.4 <- rnorm(100) df <- as.data.frame(cbind(x,y.1,y.2,y.3,y.4)) which I then melted dfmelt <- melt(df, measure.vars=2:5) The facet_wrap as shown in this solution ( Multiple plots by factor in ggplot (facets) ) gives me out each variable in an individual plot, but I would