Questions tagged [boxplot]

Boxplot is a form of displaying cardinally scaled data displaying robust summary statistics as graphical elements.

A boxplot (or a box-and-whisker plot) is a mean of displaying cardinally scaled data. The graphic displays robust summary statistics of a given dataset. These include for the box: the median, the lower quartile and the upper quartile. The enclosed whiskers are not commonly defined and may display some figure tied to the inter quartile range (e.g. IQR x 1.5) or the maxima/minima. Sometimes outliers are displayed as well.

Boxplots may easily be created by most statistical packages such as:

boxplot(rnorm(100)) #For R
boxplot(randn(100)) %For Matlab
graph box variable  'For Stata
boxplot(data)       #For matplotlib (python)
boxplot(dataframe)  #For seaborn (python)

Link:

3351 questions
27
votes
2 answers

R - ordering in boxplot

I am trying to produce a series of box plots in R that is grouped by 2 factors. I've managed to make the plot, but I cannot get the boxes to order in the correct direction. My data farm I am using looks like this: Nitrogen Species Treatment 2 …
Robert
  • 271
  • 1
  • 3
  • 3
27
votes
2 answers

Joining means on a boxplot with a line

I have a boxplot showing multiple boxes. I want to connect the mean for each box together with a line. The boxplot does not display the mean by default, instead the middle line only indicates the median. I tried ggplot(data, aes(x=xData, y=yData,…
nixbox
  • 345
  • 1
  • 4
  • 8
27
votes
2 answers

Box plot with min, max, average and standard deviation

I want to create a boxplot using the minimum, maximum and average output and standard deviation of a dataset. The examples I found, plot a numerical distribution, but in my case, this is not feasible. Is there any way to do this in Python…
Crista23
  • 3,203
  • 9
  • 47
  • 60
26
votes
2 answers

tick frequency when using seaborn/matplotlib boxplot

I am plotting with seaborn a series of boxplots with sns.boxplot(full_array) where full_array contains 200 arrays. Therefore, I have 200 boxplots and ticks on the x-axis from 0 to 200. The xticks are too close to each other and I would like to show…
Michele
  • 263
  • 1
  • 3
  • 6
26
votes
2 answers

Show mean in the box plot

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…
parth patel
  • 435
  • 2
  • 6
  • 15
26
votes
5 answers

Grouping boxplots in seaborn when input is a DataFrame

I intend to plot multiple columns in a pandas dataframe, all grouped by another column using groupby inside seaborn.boxplot. There is a nice answer here, for a similar problem in matplotlib matplotlib: Group boxplots but given the fact that…
Arman
  • 927
  • 3
  • 12
  • 32
26
votes
3 answers

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

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…
user1442363
  • 800
  • 1
  • 10
  • 18
25
votes
4 answers

Combination Boxplot and Histogram using ggplot2

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 =…
Ramnath
  • 54,439
  • 16
  • 125
  • 152
25
votes
1 answer

Matplotlib boxplot x axis

It's easier to ask this with a figure. At the moment i obtain the following boxplot graph using matplotlib: Is there a way to obtain a figure like that, but with each box in a position coherent with the corresponding x-axis number (like in a…
FMarazzi
  • 583
  • 1
  • 5
  • 14
25
votes
4 answers

Adding a scatter of points to a boxplot using matplotlib

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…
Wok
  • 4,956
  • 7
  • 42
  • 64
25
votes
1 answer

Align violin plots with dodged box plots

I have this data frame set.seed(1234) x <- rnorm(80, 5, 1) df <- data.frame(groups = c(rep("group1",20), rep("group2",20), rep("group3",20), rep("group4",20)), …
Sergio.pv
  • 1,380
  • 4
  • 14
  • 23
24
votes
2 answers

create boxplots with transparent colour ggplot2

I create a graphic with several groups and plotting a geom_boxplot() over a seet of lines. However, it would be nice to colour the boxes transparently so that the lines can be seen. Here's some sample data: x11() name <- c("a", "a", "a", "a", "a",…
Seb
  • 5,417
  • 7
  • 31
  • 50
24
votes
3 answers

How to create a grouped boxplot in R?

I want to merge the three datasets grouped and obtain a graph with only two boxes, 1 for A and 1 for B. Can you suggest how to get that? I'm tryng to create a grouped boxplot in R. I have 2 groups: A and B, in each group I have 3 subgroups with 5…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
24
votes
4 answers

How can I sort a boxplot in pandas by the median values?

I want to draw a boxplot of column Z in dataframe df by the categories X and Y. How can I sort the boxplot by the median, in descending order? import pandas as pd import random n = 100 # this is probably a strange way to generate random data; please…
Fred S
  • 1,421
  • 6
  • 21
  • 37
23
votes
2 answers

ggplot2 width of boxplot

I was trying to make 2 separate plots which I want to present side by side in my poster (I need to make them separate and cannot make use of facet_wrap). One of the plots has several boxplots, while the second plot only has one. How can I manipulate…
bsmith
  • 389
  • 2
  • 3
  • 13