如何在ggplot 2

时间:2017-09-29 05:22:22

标签: r ggplot2

(图片也是因为我的3k屏幕,对不起)

我制作了如下情节:

enter image description here

由于某些原因,我需要y轴上的刻度从0开始,但是省略上面的0到40范围内的所有刻度,并从0开始,省略0到0范围内的所有刻度下部为0.5

例如:

enter image description here

我不知道如何在ggplot2中调整我的代码,有人可以帮忙吗?

如果需要,这是我的代码:

ggthemr('fresh', layout = 'scientific',
    spacing = 1, type = 'inner', line_weight = 0.6,
    )

ggplot(tmb, aes(invasion, mean, color = sediment, linetype = nitrogen)) +
    geom_ribbon(
        aes(ymin = mean - standard.error, ymax = mean + standard.error, `group = pair),`
    alpha = 0.3,
    color = NA,
    fill = "gray"
    ) +
geom_line(size = 1) +
geom_point(show.legend = TRUE) +

facet_wrap(~type, scales = "free_y", ncol = 1, strip.position = "left") + 

scale_x_discrete(breaks = NULL, expand = c(0, 0.10)) +
scale_color_discrete("Sediment",
    labels = c("No", "Yes")
    ) +
scale_linetype_discrete("Nitrogen",
    labels = c("No", "Yes")
    ) +

theme(legend.position = "bottom",
    legend.title = element_text(size = 14),
    legend.key.size = unit(2.5, "lines"),
    legend.text = element_text(size = 14),
    panel.spacing.x = unit(0.5, "lines"),
    panel.spacing.y = unit(0.5, "lines"),
    axis.text = element_text(size = 14),
    strip.text.x = element_text(size = 10),
    strip.text.y = element_text(size = 18, margin = margin(0, 0, 0, 5)),
    strip.placement = "outside",
    axis.title.y = element_text(size = 18),
    axis.title.x = element_text(size = 18),
    aspect.ratio = 1 / 1) +

xlab("From not invaded to invaded") +
ylab(NULL)

非常感谢。

0 个答案:

没有答案