在ggplot中向内更改滴答位置

时间:2016-05-03 15:28:43

标签: r ggplot2 axis

我想将ggplot图中的刻度位置更改为向内位置。 ProcessBuilder pb = new ProcessBuilder("test.sh", arg1, arg2); Process p = pb.start(); 已弃用,因此我尝试使用axis.ticks.margin功能,但无法设法执行此操作。任何人都可以帮助我吗?

以下是一个示例数据集axis.text

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")

1 个答案:

答案 0 :(得分:-2)

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")))