1

Ok lets take some basic data:

data <- rnorm(n = 1000, mean = 50, sd = 10)
data <- round(data, digits = 0)

We can plot these with:

boxplot(data, horizontal = TRUE)
stripchart(data, vertical = FALSE, method = 'jitter', add = TRUE, pch=16, col='blue')

enter image description here We can method = jitter, overplot or stack. link

When we use stack, we see the various counts of each, like a histogram. Now we want to create a link with a single point per count (as represented by the overplot) with a shading of the counts. How can one apply a shading to a stripchart to represent the counts of data. Solutions can be in base R or with ggplot2

RHA
  • 3,677
  • 4
  • 25
  • 48
lukeg
  • 1,327
  • 3
  • 10
  • 27
  • Can you elaborate on what you mean with 'shading of the counts'? Is it a histogram-like structure? – Heroka Sep 17 '15 at 08:39
  • 1
    Related post for ggplot: [Combination Boxplot and Histogram using ggplot2](http://stackoverflow.com/questions/4551582/combination-boxplot-and-histogram-using-ggplot2) – zx8754 Sep 17 '15 at 09:15

1 Answers1

2

Is this what you are after? A transparent histogram over your boxplot?

data <- rnorm(n = 1000, mean = 50, sd = 10)
data <- round(data, digits = 0)


boxplot(data, horizontal = TRUE)
stripchart(data, vertical = FALSE, method = 'stack', 
           add = TRUE, pch=15, col=rgb(0, 0, 0, 0.2), cex = 0.7)

enter image description here

RHA
  • 3,677
  • 4
  • 25
  • 48