boxplot

How to add a number of observations per group and use group mean in ggplot2 boxplot?

情到浓时终转凉″ 提交于 2019-11-27 01:21:58
I am doing a basic boxplot where y=age and x=Patient groups age <- ggplot(data, aes(factor(group2), age)) + ylim(15, 80) age + geom_boxplot(fill = "grey80", colour = "#3366FF") I was hoping you could help me out with a few things: 1) Is it possible to include a number of observations per group above each group boxplot (but NOT on the X axis where my group labels are) without having to do this in paint :)? I have tried using: age + annotate("text", x = "CON", y = 60, label = "25") where CON is the 1st group and y = 60 is ~ just above the boxplot for this group. However, the command didn't work.

jitter if multiple outliers in ggplot2 boxplot

孤人 提交于 2019-11-27 00:58:23
问题 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

Combination Boxplot and Histogram using ggplot2

限于喜欢 提交于 2019-11-27 00:29:45
问题 I am trying to combine a histogram and boxplot for visualizing a continuous variable. Here is the code I have so far require(ggplot2) require(gridExtra) p1 = qplot(x = 1, y = mpg, data = mtcars, xlab = "", geom = 'boxplot') + coord_flip() p2 = qplot(x = mpg, data = mtcars, geom = 'histogram') grid.arrange(p2, p1, widths = c(1, 2)) It looks fine except for the alignment of the x axes. Can anyone tell me how I can align them? Alternately, if someone has a better way of making this graph using

Boxplots in matplotlib: Markers and outliers

白昼怎懂夜的黑 提交于 2019-11-26 23:58:12
问题 I have some questions about boxplots in matplotlib: Question A . What do the markers that I highlighted below with Q1 , Q2 , and Q3 represent? I believe Q1 is maximum and Q3 are outliers, but what is Q2 ? Question B How does matplotlib identify outliers ? (i.e. how does it know that they are not the true max and min values?) 回答1: Here's a graphic that illustrates the components of the box from a stats.stackexchange answer. Note that k=1.5 if you don't supply the whis keyword in Pandas. The

Adding a simple lm trend line to a ggplot boxplot

谁都会走 提交于 2019-11-26 23:13:51
问题 When adding a linear model trend line to a boxplot using standard R graphics I use: boxplot(iris[,2]~iris[,1],col="LightBlue",main="Quartile1 (Rare)") modelQ1<-lm(iris[,2]~iris[,1]) abline(modelQ1,lwd=2) However, when using this in ggplot2: a <- ggplot(iris,aes(factor(iris[,1]),iris[,2])) a + geom_boxplot() + geom_smooth(method = "lm", se=FALSE, color="black", formula=iris[,2]~iris[,1]) I get the following error: geom_smooth: Only one unique x value each group.Maybe you want aes(group = 1)?

Merge and Perfectly Align Histogram and Boxplot using ggplot2

天大地大妈咪最大 提交于 2019-11-26 22:47:29
since yesterday I am reading answers and websites in order to combine and align in one plot an histogram and a boxplot generated using ggplot2 package. This question differs from others because the boxplot chart needs to be reduced in height and aligned to the left outer margin of the histogram . Considering the following dataset: my_df <- structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,

Show mean in the box plot in python?

会有一股神秘感。 提交于 2019-11-26 20:58:41
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . I am new to Matplotlib, and as I am learning how to draw box plot in python, I was wondering if there is a way to show mean in the box plots? Below is my code.. from pylab import * import matplotlib.pyplot as plt data1=np.random.rand(100,1) data2=np.random.rand(100,1) data_to_plot=[data1,data2] #Create a figure instance fig = plt.figure(1, figsize=(9, 6)) # Create an axes

How to change x-axis tick label names, order and boxplot colour using R ggplot?

ぐ巨炮叔叔 提交于 2019-11-26 19:38:56
问题 I have a folder containing csv files, each with two columns of data e.g.: 0,red 15.657,red 0,red 0,red 4.429,red 687.172,green 136.758,green 15.189,red 0.152,red 23.539,red 0.348,red 0.17,blue 0.171,red 0,red 61.543,green 0.624,blue 0.259,red 338.714,green 787.223,green 1.511,red 0.422,red 9.08,orange 7.358,orange 25.848,orange 29.28,orange I am using the following R code to generate the boxplots: files <- list.files(path="D:/Ubuntu/BoxPlots/test/", pattern=NULL, full.names=F, recursive=FALSE

matplotlib: Group boxplots

人盡茶涼 提交于 2019-11-26 19:33:46
Is there a way to group boxplots in matplotlib? Assume we have three groups "A", "B", and "C" and for each we want to create a boxplot for both "apples" and "oranges". If a grouping is not possible directly, we can create all six combinations and place them linearly side by side. What would be to simplest way to visualize the groupings? I'm trying to avoid setting the tick labels to something like "A + apples" since my scenario involves much longer names than "A". Molly How about using colors to differentiate between "apples" and "oranges" and spacing to separate "A", "B" and "C"? Something

In ggplot2, what do the end of the boxplot lines represent?

主宰稳场 提交于 2019-11-26 19:11:27
问题 I can't find a description of what the end points of the lines of a boxplot represent. For example, here are point values above and below where the lines end. (I realize that the top and bottom of the box are 25th and 75th percentile, and the centerline is the 50th). I assume, as there are points above and below the lines that they do not represent the max/min values. 回答1: The "dots" at the end of the boxplot represent outliers. There are a number of different rules for determining if a point