ggplot map
ggplot {ggplot2} | R Documentation |
Create a new ggplot
Description
ggplot()
initializes a ggplot object. It can be used to declare the input data frame for a graphic and to specify the set of plot aesthetics intended to be common throughout all subsequent layers unless specifically overridden.
Usage
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())
Arguments
data |
Default dataset to use for plot. If not already a data.frame, will be converted to one by |
mapping |
Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot. |
... |
Other arguments passed on to methods. Not currently used. |
environment |
DEPRECATED. Used prior to tidy evaluation. |
Details
ggplot()
is used to construct the initial plot object, and is almost always followed by +
to add component to the plot. There are three common ways to invoke ggplot
:
ggplot(df, aes(x, y, other aesthetics))
ggplot(df)
ggplot()
The first method is recommended if all layers use the same data and the same set of aesthetics, although this method can also be used to add a layer using data from another data frame. See the first example below. The second method specifies the default data frame to use for the plot, but no aesthetics are defined up front. This is useful when one data frame is used predominantly as layers are added, but the aesthetics may vary from one layer to another. The third method initializes a skeleton ggplot
object which is fleshed out as layers are added. This method is useful when multiple data frames are used to produce different layers, as is often the case in complex graphics.
Examples
# Generate some sample data, then compute mean and standard deviation
# in each group
df <- data.frame(
gp = factor(rep(letters[1:3], each = 10)),
y = rnorm(30)
)
ds <- plyr::ddply(df, "gp", plyr::summarise, mean = mean(y), sd = sd(y)) # The summary data frame ds is used to plot larger red points on top
# of the raw data. Note that we don't need to supply `data` or `mapping`
# in each layer because the defaults from ggplot() are used.
ggplot(df, aes(gp, y)) +
geom_point() +
geom_point(data = ds, aes(y = mean), colour = 'red', size = 3) # Same plot as above, declaring only the data frame in ggplot().
# Note how the x and y aesthetics must now be declared in
# each geom_point() layer.
ggplot(df) +
geom_point(aes(gp, y)) +
geom_point(data = ds, aes(gp, mean), colour = 'red', size = 3) # Alternatively we can fully specify the plot in each layer. This
# is not useful here, but can be more clear when working with complex
# mult-dataset graphics
ggplot() +
geom_point(data = df, aes(gp, y)) +
geom_point(data = ds, aes(gp, mean), colour = 'red', size = 3) +
geom_errorbar(
data = ds,
aes(gp, mean, ymin = mean - sd, ymax = mean + sd),
colour = 'red',
width = 0.4
)
ggplot map的更多相关文章
- R语言-ggplot初级
ggplot2简介: 在2005年开始出现,吸取了基础绘图系统和lattice绘图系统的优点,并利用一个强大的模型来对其进行改进,这一模型基于之前所述的一系列准则, 能够创建任意类型的统计图形 1.导 ...
- ggplot ggplot2 画图
折线图-ggplot2 http://blog.163.com/yugao1986@126/blog/static/6922850820131161531421/http://blog.sina.c ...
- R ggplot学习笔记1
R 可视化学习笔记 记参数挺费劲的,还是用的时候查官方文档吧,现在记个大概就行吧~ 1.ggplot2分层次绘图 1.1 核心理念 把绘图与数据分离,把数据相关的绘图与数据无关的绘图分离,按图层作图. ...
- mapreduce中一个map多个输入路径
package duogemap; import java.io.IOException; import java.util.ArrayList; import java.util.List; imp ...
- .NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法
.NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法 0x00 为什么需要Map(MapWhen)扩展 如果业务逻辑比较简单的话,一条主管道就够了,确实用不到 ...
- Java基础Map接口+Collections工具类
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- Java基础Map接口+Collections
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- 多用多学之Java中的Set,List,Map
很长时间以来一直代码中用的比较多的数据列表主要是List,而且都是ArrayList,感觉有这个玩意就够了.ArrayList是用于实现动态数组的包装工具类,这样写代码的时候就可以拉进 ...
- Java版本:识别Json字符串并分隔成Map集合
前言: 最近又看了点Java的知识,于是想着把CYQ.Data V5迁移到Java版本. 过程发现坑很多,理论上看大部分很相似,实践上代码写起来发现大部分都要重新思考方案. 遇到的C#转Java的一些 ...
随机推荐
- vue/webpack的一些小技巧
都知道我比较懒,今天给大家分享的就是如何让自己省事. 一.vue修改打包后的结构(不知道怎么描述合理,看效果图) /config/index.js 默认的: 修改的:(顺手修改了打包后的文件名) 这样 ...
- bzoj-4887-dp+矩阵快速幂
4887: [Tjoi2017]可乐 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 247 Solved: 170[Submit][Status][D ...
- HDU 2860 (模拟+并查集)
Regroup Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- java 8 日期api
//localdatetime -> string LocalDateTime now = LocalDateTime.now(); String format = now.format(Dat ...
- Windows 7 IIS7.5上部署MVC实例
这段时间在用MVC写一个导游网站,在Window7上部署的时候,遇到和处理了一些问题. 现将完整的过程整理出来,供大家参考: 一.部署准备: 1.安装Microsoft .net FrameWork ...
- Location对象的页面跳转方法介绍
JavaScript中使用location对象可以通过很多种方式改变浏览器的位置.最常用的方法应该是下面几种: demo.js 1 2 3 location.href = "http://w ...
- 穷举算法和递推算法(Java)
穷举算法 概念: 最简单算法,依赖计算机的强大计算能力穷尽每一种可能的情况.穷举算法效率不高,但是适合一些没有明显规律可循的场合. 思想: 在使用穷举算法时,需要明确问题答案的范围,这样才可能在指定范 ...
- C++的explicit关键字
C++程序员对于explicit这个关键字其实不是很熟悉,至少我是如此:原因在于其使用范围不大,而且作用也没有那么大. 但是这不是说明我们的程序中不需要这个关键字,按Google的C++编程规范和Ef ...
- 首次运行tensorflow-gpu 1.0 报错 failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
发现博客: https://blog.csdn.net/u010752600/article/details/79534910 于是找到解决方法. sudo rm -rf ~/.nv/
- 實驗項目wordcount
wordcount 1.设计思路 第一步 :主函数参数使用命令行参数,定义一个文件指针fp. 第二步:判断能否用只读的形式打开命令行指针中的文件,并让指针指向打开函数,若不能则输出不能读取文件,否则下 ...