[R] ggplot interactions
Ista Zahn
istazahn at gmail.com
Wed Sep 11 20:30:03 CEST 2013
Hi Robert,
It is really hard to follow this without the data or a reproducible
example. Also your attachments did not come through. Please read the
posting guide and re-formulate your question to make it easier to help
you. Finally, note that there is a separate ggplot2 mailing list at
https://groups.google.com/forum/?fromgroups#!forum/ggplot2
Best,
Ista
On Wed, Sep 11, 2013 at 1:53 PM, Robert Lynch <robert.b.lynch at gmail.com> wrote:
>> I am sorry to ask what I am sure is a simple question but I am stuck
>> trying to figure out how different parts of ggplot2 calls interact
>>
>> I am plotting using the following code
>>
>> ggplot(Chem.comp, aes(Course, GRADE)) + geom_boxplot(notch = TRUE,aes(fill
>> = COHORT))+
>> labs(y ="Grade Points in class",
>> x = "Chemistry 2 quarter") +
>> ggtitle(expression(atop("Comparison between ISE cohorts and Peers",
>> atop(italic("in Chem 2 classes"), ""))))
>> ylim(0,4.3333)+
>> scale_fill_manual(name = "ISE Cohorts &\nComparison groups",
>> values =
>> c("blue","red","blue3","red3","blue4","red4")) +
>> theme(plot.title = element_text(size = 25, face = "bold", colour =
>> "black", vjust = -1))+
>> guides(fill = guide_legend(nrow = 3),byrow = TRUE)
>>
>> which gives me a plot [available as a jpeg, not attached due to size
>> limits] which is has the appropriate title, but the colors and the legend
>> are wrong. The colors cycle through R's standard colors, and the legend is
>> 1 column.
>>
>> if I comment out the ggtitle() and theme(), or just ggtitle() I get a plot
>> [available, but not attached ue to size limits] which has the right colors
>> and mostly right legend, but no title and subtitle. The legend is out of
>> order. the first row should read ISE07 CMP07 with 08 on the second row and
>> 09 the third with a red column and a blue column. Changing byrow = TRUE to
>> bycol = TRUE does not change the plotting of the legend nor does byrow=FALSE
>>
>> I am asking for help with getting the title and sub-title to both show up
>> at the same time as the appropriate colors for the different factor levels.
>> And to get the legend to render so that the legend looks sort of like
>> ISE07[red box] [blue box ]CMP07
>> ISE08 [red3 box] [blue3 box]CMP08
>> ISE09 [red4 box] [blue4 box]CMP09
>> the exact colors are not important but the the vertical
>> and horizontal alignment is.
>>
>> Thanks!
>> Robert
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list