在 R 中使用多因素生成单独的点图
我正在尝试在 R 中生成具有多个因素的单个点图,该图与 minitab 生成的点图类似。
我已经能够在 R 中生成单独的点图,但我不知道如何向 x 轴添加分组。例如,我有一个颜色和一个类型,我想在 x 轴上显示,每个类型都有两种颜色,我希望将其放在同一个图表上,但无法弄清楚点图。
结果应该与此分组类似,但是是一个点图,并且只有 1 个图表,我只是想说明分组。
http://ajpendo.physicalology.org/content/280/5 /E804/F6.small.gif
抱歉,无法发布图像,太菜鸟了:)
我已经搜索过网络,但找不到太多帮助。
有什么想法吗?
I'm trying to generate an individual dot plot with multiple factors in R that's similar to the one produced by minitab.
I've been able to produce the individual dot plot in R but I can't figure out how to add grouping to the x-axis. For example I have a Color and a Type that I'd like to display on the x-axis, each Type has two colors and I'd like this put on the same graph but can't figure it out for a dot plot.
The result should look similar to this grouping but a dot plot instead and only have 1 graph, I'm just trying to illustrate the grouping.
http://ajpendo.physiology.org/content/280/5/E804/F6.small.gif
sorry can't post the image, too much of a noob to stack :)
I've scoured the web but can't find much help.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 R 中通过多种方式执行此操作。
第一种是使用
lattice
包:第二个在 ggplot 中:
You can do this in a number of ways in R.
The first is to use the
lattice
package:And the second is in ggplot:
您可以使用 ggplot 最直接地执行此操作。假设您有一个包含以下列的 data.frame:
dta := x, y, color, condition
其中 x,y 是数字,color, condition 是因子。然后你可以执行以下操作:
或者,在常规 R 中你可以执行以下操作:
但是,这可能太忙了。
吉姆
You can use ggplot to do this most directly. Let's say you have a data.frame with the following columns:
dta := x, y, color, condition
where x,y are numeric and color, condition are factors. Then you can do the following:
alternatively, in regular R you could do:
however, this might be way too busy.
jim