geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
# sample data
d <- data.frame(expand.grid(x=letters[1:4], g=factor(1:2)), y=rnorm(8)) # Figure 1a, 1b, and 1c.
ggplot(d, aes(x=x, y=y, colour=g)) + opts(title="Figure 1a") + geom_line() + geom_point()
ggplot(d, aes(x=x, y=y, colour=g, group=g)) + opts(title="Figure 1b") + geom_line() + geom_point()
ggplot(d, aes(x=x, y=y, colour=g, group=1)) + opts(title="Figure 1c") + geom_line() + geom_point()
The figure 1a does not draw any lines, while the figure 1b works well.
The key concept is “group” in aes.
The rule is simple:
- geom_line() tries to connect data points that belong to same group.
- different levels of factor variable belong to different group.
So, by specifying group=g in aes, the lines appear in Figure 1b.
Figure 1c would help to understand more.
In Figure 1c, all data points belong to group=1, hence all data points are connected.
REF:
https://kohske.wordpress.com/2010/12/27/faq-geom_line-doesnt-draw-lines/
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?的更多相关文章
- [R] 添加误差棒的分组折线图:geom_path: Each group consists of only one observation. Do you need to adjust the...
想做一个简单的分组折线图,并添加误差棒,类似下面这样的: 用ggplot似乎很简单就能实现:ggplot+geom_errorbar+geom_line+geom_point,重点在于计算误差棒. 还 ...
- R语言学习 - 线图绘制
线图是反映趋势变化的一种方式,其输入数据一般也是一个矩阵. 单线图 假设有这么一个矩阵,第一列为转录起始位点及其上下游5 kb的区域,第二列为H3K27ac修饰在这些区域的丰度,想绘制一张线图展示. ...
- Kafka消费组(consumer group)
一直以来都想写一点关于kafka consumer的东西,特别是关于新版consumer的中文资料很少.最近Kafka社区邮件组已经在讨论是否应该正式使用新版本consumer替换老版本,笔者也觉得时 ...
- Oracle学习笔记五 SQL命令(三):Group by、排序、连接查询、子查询、分页
GROUP BY和HAVING子句 GROUP BY子句 用于将信息划分为更小的组每一组行返回针对该组的单个结果 --统计每个部门的人数: Select count(*) from emp group ...
- sql 单个字段去重查询 distinc 和 group by的效率问题
sql 查询 distinc用法 distinct 和group by都需要排序,一样的结果集从执行计划的成本代价来看差距不大,但group by 还涉及到统计,所以应该需要准备工作.所以单纯从等价结 ...
- SQL中Group By的使用
1.概述 2.原始表 3.简单Group By 4.Group By 和 Order By 5.Group By中Select指定的字段限制 6.Group By All 7.Group By与聚合函 ...
- GROUP BY的扩展
GROUP BY的扩展主要包括ROLLUP,CUBE,GROUPING SETS三种形式. ROLLUP rollup相对于简单的分组合计增加了小计和合计,解释起来会比较抽象,下面我们来看看具体事例. ...
- MySQL高级查询 之 与 Group By 一起使用的函数 和 关键字
1 GROUP_CONCAT mysql> SELECT student_name, -> GROUP_CONCAT(test_score) -> FROM stud ...
- MySQL有关Group By的优化
昨天我写了有关MySQL的loose index scan的相关博文(http://www.cnblogs.com/wingsless/p/5037625.html),后来我发现上次提到的那个优化方法 ...
随机推荐
- Debian自带浏览器IceWeasel的中文化
Iceweasel浏览器简体中文组件 # Iceweasel是Debian中Mozilla Firefox浏览器的一个再发布版#英语很菜,所以浏览器菜单也要是中文的sudo apt-get insta ...
- php里session的用法
PHP中的session默认情况下是使用客户端的Cookie.当客户端的Cookie被禁用时,会自动通过Query_String来传递. Php处理会话的函数一共有11个,我们详细介绍一下将要用到几个 ...
- 如何在视频处理控件TVideoGrabber中设置音频捕捉设备
TVideoGrabber不仅可以捕捉视频,还可以作为多媒体播放器,并支持包括C#..NET.VB.NET.C++.Delphi.C++Builder和ActiveX平台,本文将剖析TVideoGra ...
- 启动管理软件服务器时,提示midas.dll错误
首先确认系统以及管理软件目录内是否有midas.dll文件,如果没有,请复制或下载midas.dll到相应目录.系统默认路径为:'c:\windows\system32\' 然后依次打开“开始菜单”内 ...
- iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
Apple官方的文档为生成一个UIImage对象提供了两种方法: 1. imageNamed,其参数为图片的名字: 2. imageWithContentsOfFile,其参数也是图片文件的路径. ...
- HDU 3078:Network(LCA之tarjan)
http://acm.hdu.edu.cn/showproblem.php?pid=3078 题意:给出n个点n-1条边m个询问,每个点有个权值,询问中有k,u,v,当k = 0的情况是将u的权值修改 ...
- hdwik中view模块的应用
概述 MVC中的视图view 主要负责页面显示部分,所有的页面显示全部在此实现,视图对整个页面负责,它通过control的调用来显示页面和数据.视图(view)类template.cla ...
- [HTML]表格的一切
如何设置HTML页面自适应宽度的table(表格): <table width="95%" border="1" cellpadding="2& ...
- c# 之抽象工厂模式
Email整体项目 Email类 using System; using System.Collections.Generic; using System.Linq; using System.Tex ...
- H - Solve this interesting problem 分类: 比赛 2015-07-29 21:06 15人阅读 评论(0) 收藏
Have you learned something about segment tree? If not, don't worry, I will explain it for you. Segm ...