[R] ggplot2 boxplot points (size,color,shape)

Thierry Onkelinx thierry.onkelinx at inbo.be
Tue Mar 17 15:28:23 CET 2015


You need to set the shape manually

library(ggplot2)
n <- 200
dataset <- data.frame(
  Type = sample(c("A", "B"), n, replace = TRUE),
  Value = rnorm(n)
)
ggplot(dataset, aes(x = Type, y = Value)) + geom_boxplot() +
geom_jitter(aes(shape = Type)) + scale_shape_manual(values = c(1, 19))


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-03-17 15:04 GMT+01:00 Brian Smith <bsmith030465 op gmail.com>:

> Hi,
>
> I am trying to create a boxplot (with geom_jitter) such that the points
> from one set of values are shown as circles, and the second set of points
> also as circles, but with no fill. In other words, how can I control the
> shape and color for the points appearing in this boxplot?
>
> =======
> library(ggplot2)
>
> myvect1 <- rnorm(100)
> myvect2 <- rnorm(100)
>
> fill1 <- rep('solid',100)
> fill2 <- rep('solid',100)
>
> myvect <- c(myvect1,myvect2)
> myfill <- c(fill1,fill2)
>
> mydat <- data.frame(myvect,myfill)
>
> ## How can I control the shape, color of the points in the boxplot based on
> the values of myfill?
> ggplot(data=mydat,aes(x='test',y=myvect)) + geom_boxplot() + geom_jitter()
>
> ==========
>
> thanks!!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list