jrnold / ggthemes

Additional themes, scales, and geoms for ggplot2
http://jrnold.github.io/ggthemes/
1.31k stars 229 forks source link

Secondary (i.e. top) x-axis text overlaps edge of plot #115

Closed burchill closed 3 years ago

burchill commented 4 years ago

I noticed that when I used ggthemes::theme_economist() on a plot with a secondary x-axis at the top of the plot, the text labels for that top axis overlap with the top-edge of the plot. Example below:

library(ggplot2)

data.frame(x=rnorm(20),y=rnorm(20)) %>%
  ggplot(aes(x=x, y=y)) +
  geom_point() +
  scale_x_continuous(sec.axis = dup_axis(trans=~.)) + 
  ggthemes::theme_economist() 

This seems to be fixed when I add theme(axis.text.x.top = element_text(vjust = 0, margin = margin(b = base_size, unit = "pt")) to the theme.

jrnold commented 3 years ago

Thanks for the example and code! I fixed this upcoming version.