问题标签 [facet-wrap]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - 更改 facet_wrap 中构面的顺序
我正在尝试使用facet_wrap
但默认情况下绘制一些信息,标题的顺序是按字母顺序排列的。我的方面的标题是月份名称,我希望它们按正确的顺序排列(Jan、Feb、Mar ....)。我正在使用以下代码:
生成以下图:
这是输出dput(head(avgRevenueBySubject))
我想按时间顺序排列这些方面。任何帮助将非常感激。
r - 如何在ggplot中使用coord_cartesian更改每个方面的ylim?
此答案描述了如何更改 ggplot 中绘图的 y 限制。假设我有一个分面图,每个方面都有不同的 ylim,例如
如何以不同方式更改每个方面的 y 限制?
r - Change the number of breaks using facet_grid in ggplot2
I have a kind of data such as:
and when I use facet_grid() with scales="free_x" option I obtain 5 graphs with different number of breaks. It is possible that the 5 graphs have the same number of breaks? For example 3.
I know that if I remove the scales="free_x" option I obtain the same scale for the 5 graphs, but the plot it turns so ugly. Can you help me?
r - R/ggplot: Vertical strip text with facet_wrap
I'm using ggplot in R to plot several conditions with facet_wrap. I'd like to put the strip with the plot name on the vertical axis on the right instead of on top.
This is an example:
Here the plot names (A, B, C, D, E) are on top, I'd like them to be on the right as in here:
Is there an easy switch to do it?
(I'm not using facet_grid
since I'd like to use the options nrow
and ncol
that come with facet_wrap
).
Thanks! Dario
r - 使用 scales = 'free' 在 facet_wrap 中设置 x/y 限制
我已经看到过类似的问题,以及有关向ggplot Setting x/y lim in facet_grid添加功能的讨论。在我的研究中,我经常想要制作几个面板图,例如针对不同的模拟试验,其中轴限制保持不变以突出试验之间的差异。这在演示文稿中显示绘图面板时特别有用。在我制作的每个面板图中,各个图需要独立的 y 轴,因为它们通常是天气变量、温度、相对湿度、风速等。使用
效果很好,因为我可以轻松制作不同天气变量的绘图面板。
当我比较不同的绘图面板时,有一致的轴很好。不幸的是, ggplot无法设置面板图中每个图的单独限制。它默认使用给定数据的范围。上面链接的 Google Group 讨论讨论了这个缺点,但我找不到任何关于是否可以添加的更新。有没有办法欺骗ggplot设置个人限制?
r - Adding mean value to facets
I have this plot, which calculates an index of abbundance of a bird species for a given winter:
This graphic comes from this code (themes and scales excluded):
and the data frame has 6 variables:
pentada / censos / yr / total / inv / ika
The thing is that I would like to add a line in each of the wintering seasons that shows the mean of the abbundance for all the years combined and I don't know how. should I append the mean as a new column after every wintering season? In this case, how should I do it?.
Thank you.
r - 使用 ggplot 通过刻面或颜色编码因子在同一图形上绘制大量因子的百分比变化
这是我正在使用的代码示例
我正在尝试绘制 x 偏离 0 的程度,并按每个因素对其进行分面,如下所示:
当我有三个因素时,这很好用(忽略*:我有一个重要性列,我已经删除了它。
下面的例子:
但是,我总共有 8 个因子,并且刻面模糊了绘图,使得每个 x 值与零的距离变得非常扭曲。
下面的例子
所以,我的问题是:考虑到我在 ggplot 中使用分面或颜色编码的大量 x 值和因子,有什么更好的方法来编码/渲染这个图?
我会非常愿意按因子而不是刻面对 x 的每个距离进行颜色编码,但我一直在努力思考如何在 ggplot 中做到这一点(对 ggplot 来说非常新),所以我可以还没有说它是否会使这个数字更容易解释。
r - 在 R 中使用 facet_wrap 时向单个箱线图添加水平线(或文本)
我想为使用 facet_wrap 函数创建的每个箱线图添加一条水平线。这是我创建箱线图的代码:
这是我想用于每条水平线的数据框:
这是我最接近的:
出现的是多行,即在每个箱线图上重复的行。
我想要的是每幅图一条线,每条线对应于 dat_hlines$hline 中的观察结果
ps 我会发布图形,但我的分数不允许。
数据
r - facets 在 qplot 中工作,但 facet_wrap 在 ggplot 中产生错误
我在尝试在 ggplot 中使用 facet_wrap 时遇到了一个令人困惑的问题,其中既有我的真实数据集,也有一个简化的虚拟数据集。我正在尝试为多个个体绘制整个基因组的杂合性,每个染色体分别显示。
我的虚拟数据:
我要读取数据的代码:
当我尝试在 qplot 中分别绘制染色体时,它工作正常:
但是当我在 ggplot 中尝试类似的事情时,它不起作用。第一部分工作正常:
但是当我尝试添加 facet_wrap 时:
这会产生以下错误
“错误 en layout_base(data, vars, drop = drop) : 至少一层必须包含用于构面的所有变量”
我尝试将 (as.formula(paste)) 添加到 facet_wrap() 并直接调用 hetshoms$V1 但都没有解决问题。
对于如何更正我的代码的任何建议,我将不胜感激。
r - 如何在多面图中为 geom_vline 设置线型?
下面的代码就像一个魅力:
以下代码删除线型。为什么?
我在 Rstudio 中使用 ggplot 0.9.3.1。