Brilliant - thanks very much for your help!

Tom

On 6 May 2014 23:08, David Winsemius <dwinsem...@comcast.net> wrote:
>
> On May 6, 2014, at 2:51 PM, Tom Walker wrote:
>
>> 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")
>>
>
> Just changing that assignment to create an expression vector instead of a 
> list works in R 3.1.0 Patched and ggplot2_0.9.3.1
>
> mylabels <- c(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!
>
> Thanks for providing complete example.
>
>>
>> Many thanks,
>>
>> Tom
>>
>> _
>
> David Winsemius
> Alameda, CA, USA
>

______________________________________________
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