Hi,

I need to generate bar charts where the x-axis is a factor that
includes a mixture of species names (in italic) and control treatments
(in plain text).

I would like this to be represented in the contents of the axis
labels, meaning that I need the x-axis to include both italic and
plain text. An example of my failed attempt is below (the bins in the
label list containing expressions become blank).

d <- data.frame(Category = c("Sphagnum plant", "Calluna plant",
"Eriophorum plant", "Control"),
                Response = c(1, 3, 5, 6))

d

mylabels <- list(expression(paste(italic("Sphagnum"), " plant")),
                 expression(paste(italic("Calluna"), " plant")),
                 expression(paste(italic("Eriophorum"), " plant")),
                 "Control")

ggplot(d) +
  aes(x = Category, y = Response) +
  geom_bar() +
  scale_x_discrete(labels = mylabels)

Any help would be much appreciated!

Many thanks,

Tom

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to