[R] How to set colors, axis gap, and free scale in ggplot?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Tue Feb 22 15:09:58 CET 2022


No wonder it was not working: I was using the wrong functions (so far
of manuals....)
This is great, thank you! All tips worked fine, including the free axis scale.

On Tue, Feb 22, 2022 at 12:41 PM Ron Crump <r.e.crump using warwick.ac.uk> wrote:
>
> Hi Luigi,
>
> > # FROM HERE IT DOES NOT WORK
> > facet_grid(. ~ Species, scales="free_y") + # THE SCALE IS FIXED FOR ALL PANELS
>
> I don't think you can force facet_grid to do this: the y scale will
> always be fixed within a row (unless someone else tells you differently,
> I may have misunderstood this)  - this is to allow easy comparison and,
> consequently, comprehension of the graphic as you scan across a row.
>
> You can achieve what you want with:
> facet_wrap(~ Species, nrow = 1, scales = "free_y")
> but for the reason above, I'm not sure it's a good thing to do.
>
> > scale_colour_manual(values = c("palegreen4", "orangered3")) # THE
> > COLORS ARE AUTOMATIC
>
> You're setting the colour manually - which relates to lines, not fill
> and you have no colour aesthetic set, just a fill one.
>
> Use scale_fill_manual(values = c("palegreen4", "orangered3")) instead.
>
> > I would also like to increase the size of the axis labels and the
> > title size of the panels.
> > What is the correct syntax?
>
> See ?theme - you are interested in axis.title (maybe axis.title.x,
> axis.title.y) and strip.text (the labels for the facets). See also
> ?element_text as in theme, you basically want to put something like
> axis.title = element_text(...), replacing ... with the settings you
> want.
>
> For help specifically on ggplot2 and other tidyverse packages, I'd
> recommend using https://community.rstudio.com in the future.
>
> Best wishes,
> Ron.
>


-- 
Best regards,
Luigi



More information about the R-help mailing list