2

I like the classic look theme in ggplot2:

library(ggplot2)
thm <- theme_classic() 
theme_set(thm)

set.seed(123)
a <- data.frame(var=rnorm(2000))
ggplot(a,aes(var)) + geom_histogram()

enter image description here

As per this question, I can remove the space between the data and the axes using expand=c(0,0) in the scale_x_continuous and scale_y_continuous options.

But is there a way I can set this as the default in thm?

Ashley Naimi
  • 232
  • 1
  • 9
  • 6
    If there is an answer to this I don't think it lies in the theming system, as that is generally separate from the scales and geoms that form the content of the plot. – Marius Feb 13 '18 at 05:52
  • Also be aware that would not necessarily be generally useful, as e.g. in a scatterplot points with the smallest x or y will get cut in half. – Axeman Feb 13 '18 at 08:00
  • I agree with you that many graphs look better without the space, and with the axis starting at 0. Unfortunately, I don't think there is any way to make this a default or write it into a theme - I just include the `expand = c(0,0)` code in most plots I make. – Jan Boyer Feb 14 '18 at 17:03

0 Answers0