stefanedwards / lemon

🍋 Lemon --- Freshing up your ggplots
https://cran.r-project.org/package=lemon
GNU General Public License v3.0
183 stars 11 forks source link

coord_flex_capped draws axis text to close to ticks #14

Closed stefanedwards closed 5 years ago

stefanedwards commented 5 years ago

Aaron R. wrote:

I've noticed when I use the capped axis lines, it moves the labels closer to the ticks, and I can't figure out how to move them back. Is there some argument I can't find? Here's some reproducible code.

library(ggplot2)
library(lemon)
dat1 <- data.frame(
  gp = factor(rep(c('F','T','Z'), each = 10)),
  y = rnorm(30))
my.theme <- theme_light() + 
  theme(panel.border=element_blank(), 
        axis.line = element_line(), 
        axis.ticks = element_line(colour='black'))
p <- ggplot(dat1, aes(gp, y)) + geom_point() + my.theme

##############
#### Notice how the FTZ is closer to the tick marks in the capped version

p
p + coord_capped_cart(bottom='right')

##############
#### Normally you could bump the margin, but that doesn't work here

p + theme(axis.text.x = element_text(margin=margin(t=10)))
p + theme(axis.text.x = element_text(margin=margin(t=10))) +
  coord_capped_cart(bottom='right')
stefanedwards commented 5 years ago

ggplot2/R/guide-axis.R was slightly changed. Updates are updated.