Skip to content

Having issue trying to get plot to have plain-white background

4 messages · Bruce Miller, Mollie Brooks, Altaf Hussain +1 more

#
Hi all, This is not directly an R-Ecology question but neither the 
general R help forum nor GGplot forums has any responses.
This is an ecology based application however LOL


I need to save plots for a publication but can not seem to get he syntax 
correct to have GGPLOT use only a white background vs. the default gray one.

I have tried the various themes but nothing seems to work.
This is the existing code for the plot and followed by what I have tried 
to no avail.

Works with gray plot frame backgrounds


ggplot(polished, aes(x =Night, y = Time, colour = Species)) +

geom_point() +

**scale_colour_hue(l=40)+

ggtitle(label = ' Linderos temporal activity')+

facet_grid(. ~ Night) +facet_wrap(facets = ~Species)+

scale_y_continuous(labels = label_hours, breaks = break_hours) +

theme(axis.text.x = element_text(angle = 270))

Trying theme bw does not seem to work!
I did also load one of the "themes" packages to see if that was the 
issue.? Not.

ggplot(polished, aes(x =Night, y = Time, colour = Species)) +

geom_point() +

**scale_colour_hue(l=40)+

ggtitle(label = 'Temporal activty')+

facet_grid(. ~ Night) +facet_wrap(facets = ~Species)+

scale_y_continuous(labels = label_hours, breaks = break_hours) +

*theme_b**w*(axis.text.x=element_text(angle = 270))


Any guidance on correct syntax/usage to plot clean-white plot back 
ground? welcomed.

Bruce
#
Hi Bruce,

I like to use this line by default so that all the plots have white backgrounds.

library(ggplot2); theme_set(theme_bw())

I?m sure it?s also possible to use theme_bw() on individual plots somehow, but I haven?t tried.

cheers,
Mollie
#
I find the following code really helpful to further play with theme_bw()

myplot + theme_bw() + theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour =
"black"))

Cheers,
Altaf

On Sat, Jun 15, 2019 at 10:26 AM Mollie Brooks <mollieebrooks at gmail.com>
wrote:

  
  
#
Hi,

I think what you need is just this:

myplot + theme_classic()

It gives you a complete white background, different from theme_bw(), which gives you a white background combined with a grey grid. Altaf?s solution gives the same output, but it is much longer IMO.

Best,
Jhonny

De: Altaf Hussain<mailto:altaf2 at ualberta.ca>
Enviado:15 June 2019 19:36
Para: Mollie Brooks<mailto:mollieebrooks at gmail.com>
Cc:r-sig-ecology at r-project.org<mailto:r-sig-ecology at r-project.org>; Bruce Miller<mailto:batsncats at gmail.com>
Assunto: Re: [R-sig-eco] Having issue trying to get plot to have plain-white background

I find the following code really helpful to further play with theme_bw()

myplot + theme_bw() + theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour =
"black"))

Cheers,
Altaf

On Sat, Jun 15, 2019 at 10:26 AM Mollie Brooks <mollieebrooks at gmail.com>
wrote:
_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology