使用coord_cartesian时,y轴消失

时间:2020-05-27 10:03:39

标签: ggplot2 coordinates axis-labels cartesian-coordinates

我有下表:

x   var   y
a group1 0.5
b group1 -0.65
c group1 -1.3
d group1 0.2
a group2 1.2
b group2 -1.6
c group2 -0.7
d group2 -3

我想用ggplot在var(第1组或第2组)的两个不同图中绘制x与y的关系。

但是,我也想“放大”到y轴,从而显示整个x轴,但在y轴上,只有-0.5到-3的值:

ggplot(table,
       aes(x = x,
           y = y)) +
  geom_point() +
  facet_wrap(vars(var)) +
  scale_y_continuous() +
  coord_cartesian(ylim = c(-0.5, 
                          -3))

但是,这会删除y轴上的值和刻度,并且我不知道如何使其显示:

enter image description here

0 个答案:

没有答案
相关问题