包含在多个 ggplot 方面的数据子集
我有一个人口和该人口的样本。我使用 ggplot2 及其分面选项制作了一些图来比较它们,但我突然想到,将样本放在自己的分面中会扭曲总体图(无论多么轻微)。有没有办法对图进行分面,以便所有记录都在总体图中,而只有采样记录在第二个图中?
I have a population and a sample of that population. I've made a few plots comparing them using ggplot2 and its faceting option, but it occurred to me that having the sample in its own facet will distort the population plots (however slightly). Is there a way to facet the plots so that all records are in the population plot, and just the sampled records in the second plot?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
马特,
如果我正确理解你的问题 - 你想要一个多面图,其中一个面板包含所有数据,而后续的多面仅包含第一个图的子集?
可能有一种更简洁的方法来执行此操作,但您可以使用与每个子集相对应的适当分面变量创建一个新的
data.frame
对象。考虑一下:如果我误解了你的问题,请告诉我。
-追赶
Matt,
If I understood your question properly - you want to have a faceted plot where one panel contains all of your data, and the subsequent facets contain only a subset of that first plot?
There's probably a cleaner way to do this, but you can create a new
data.frame
object with the appropriate faceting variable that corresponds to each subset. Consider:Let me know if I've misunderstood your question.
-Chase