[英]How to add missing x-axis in multi faceted plot in R
I have this dataframe called cpp
. 我有一个称为
cpp
数据cpp
。 I have plotted the figure below which is missing X-axis in two of the plots in the right. 我在下面的两个图中绘制了下图,该图缺少X轴。 How can I put the x-axis for these two plots?
如何为这两个图放置x轴? Additionally, I would also like to increase the size of each box,so the lines would not touch the margin on the right.
此外,我还想增加每个框的大小,以使线条不会触及右侧的边距。
ggplot(cpp, aes(x = Num_Good, y = IBS, group = key.related.sheet, color = cutoff)) +
geom_line() + facet_wrap(~cutoff) + geom_point()
Check this answer about the "dangling" facets: add "floating" axis labels in facet_wrap plot 检查有关“悬空”构面的以下答案: 在facet_wrap图中添加“浮动”轴标签
Or as a quick workaround (if it is ok to add x axis to all facets), you can set the parameter scales = "free_x"
of facet_wrap
. 或作为一个快速的解决方法(如果它是确定x轴添加到所有方面),你可以设置参数
scales = "free_x"
的facet_wrap
。
Regarding the second part of your question, try to set the second value of the expand
parameter in scale_x_continuous
, eg: 关于问题的第二部分,请尝试在
scale_x_continuous
设置expand
参数的第二个值,例如:
ggplot(cpp, aes(x = Num_Good, y = IBS, group = key.related.sheet, color = cutoff))+
geom_line() +
facet_wrap(~cutoff, scales = "free_x") +
geom_point() +
scale_x_continuous(expand = c(0, .1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.