-2

I want to change the position of the ticks in a ggplot plot into an inward position. The axis.ticks.margin is deprecated, so I have tried to play around with axis.text function but could not manage to do it. Anyone can help me out?

Here is an example dataset df

df<- structure(list(X1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41), X2 = c(0, 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 
150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 
280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400
)), .Names = c("X1", "X2"), row.names = c(NA, -41L), class = "data.frame")

Below is what I have tried so far:

library(ggplot2)
ggplot(df, aes(x=Age, y=GPP)) + 
  geom_point()+
  theme(panel.grid = element_blank(),
        element_text(hjust=seq(from=0,to=1,length.out=6)),
        axis.text.y = element_text(margin=margin(5,5,10,5,"pt")))
SimonB
  • 670
  • 1
  • 10
  • 25

1 Answers1

-1
ggplot(df, aes(x=Age, y=GPP)) + 
  geom_point()+
  theme(panel.grid = element_blank(),
axis.ticks.length=unit(-0.25, "cm"), axis.text.x = element_text(margin=unit(c(0.5,0.5,0.5,0.5), "cm")), axis.text.y = element_text(margin=unit(c(0.5,0.5,0.5,0.5), "cm")))
SimonB
  • 670
  • 1
  • 10
  • 25