你可以为ggplot中的不同方面指定不同的geoms? [英] Can you specify different geoms for different facets in a ggplot?

查看:185
本文介绍了你可以为ggplot中的不同方面指定不同的geoms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为ggplot中的不同方面指定不同的geom?

(代表@pacomet提问,谁

  ggplot(mtcars,aes(mtcars,aes(h2_lin)>解决方案

mpg,disp))+ facet_wrap(〜cyl)+
geom_point(data = subset(mtcars,cyl == 4))+
geom_line(data = subset(mtcars,cyl == 6))+
geom_text(data = subset(mtcars,cyl == 8),aes(label = gear))


How do you specify different geoms for different facets in a ggplot?

(Asked on behalf of @pacomet, who wanted to know.)

解决方案

here is another approach by subsetting data:

ggplot(mtcars, aes(mpg, disp)) + facet_wrap(~cyl) + 
  geom_point(data = subset(mtcars, cyl == 4)) +
  geom_line(data = subset(mtcars, cyl == 6)) +
  geom_text(data = subset(mtcars, cyl == 8), aes(label = gear))

这篇关于你可以为ggplot中的不同方面指定不同的geoms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆