使用facet_wrap调整每个图形的x轴和y轴

时间:2020-05-26 02:37:19

标签: ggplot2 tidyverse ggplotly

我想调整x轴和y轴,以使每个图中的数据点更清晰易读。 (现在,所有4张图的所有x轴和y轴都相同)有人能知道我该怎么做吗?

这是我的代码:

x <- -80:50
y <- fun.1(x)
df <- data.frame(x,y)

ggplot(df, aes(x,y)) + theme_minimal() +
  geom_line(size=1) +
  geom_ribbon(ymin=-Inf, aes(ymax=y), fill='red', alpha=0.2) +
  geom_ribbon(aes(ymin=y), ymax=Inf, fill='darkgreen', alpha=0.2) +
  geom_point(aes(x=Quantity, y=Price), data = plant_mar, size = 1.5) +
  geom_label_repel(aes(x=Quantity+40, y=Price+50, label = Label), data = plant_mar, size = 2.5) +
  facet_wrap(.~Plant, scales = "free_y") +
  labs(x = "% Change in Quantity", y = "% Change in Price")

enter image description here

非常感谢您。

0 个答案:

没有答案