friendly / VCDR

Visualizing categorical data with R
0 stars 0 forks source link

ggplot2 figs should all use theme_bw(), by default #60

Closed friendly closed 8 years ago

friendly commented 8 years ago

In most nearly all ggplot2 figures, I've used + theme_bw() explicitly, except for a few that slipped, e.g., Figs 7.6, 7.7. All ggplot2 figures should use a consistent theme.

It would be better to set this globally in the Rprofile file, and tidy up the code.

friendly commented 8 years ago

This seems to be a ggplot issue, when I use ggplot in the following forms, assigning a plot to an object and printing it

<<arth-cond1, h=4, w=6, out.width='.6\\textwidth', cap='Conditional plot of Arthritis data showing separate points and fitted curves stratified by Treatment. A separate fitted curve is shown for the two treatment conditions, ignoring Sex.'>>=
library(ggplot2)
gg <- ggplot(Arthritis, aes(Age, Better, color = Treatment)) +
  xlim(5, 95) +
  geom_point(position = position_jitter(height = 0.02, width = 0)) +
  stat_smooth(method = "glm", family = binomial, alpha = 0.2,
              aes(fill = Treatment), size = 2.5, fullrange = TRUE)
gg   # show the plot
@

And:

<<arth-cond2, h=4, w=8, out.width='.8\\textwidth', cap='Conditional plot of Arthritis data, stratified by Treatment and Sex. The unusual patterns in the panel for Males signals a problem with this data.', out.extra='clip'>>=
gg + facet_wrap(~ Sex)
@