R语言低级绘图函数-arrows
arrows 函数用来在一张图表上添加箭头,只需要分别指定起始坐标和终止坐标,就可以添加箭头了,还可以通过一些属性对箭头的形状,大小进行调整
基本用法:
xo, yo 指定起始点的x和y坐标,x1, y1 指定终止点的x和y坐标, 代码示例如下:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4)
效果如下:

x0, y0,x1,y1 支持一次设置多个值,同时画多个箭头,示例代码如下:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
arrows(x0 = c(1, 1), y0 = c(1, 2), x1 = c(4, 4), y1 = c(4, 5))
效果如下:

参数调整:
length : 该参数一次只能设置一个值,默认值为0.25, 为了调整不同箭头的大小,建议分别设置,用法如下:
par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 0.1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 0.5")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 1)
效果如下:

code : 调整箭头的类型,一共有1,2,3,4 共四种类型,该参数一次只能设置一个值,四种类型具体可以看下面的效果图
代码如下:
par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 2")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 2)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 3")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 3)
效果图如下:

code = 1 代表箭头由终止点指向起始点
code = 2 是默认值,箭头由起始点指向终止点
code = 3 代表在起始点和终止点两端都标上箭头
angle : 设置箭头的角度,默认值是45,该参数一次只能设置一个值,代码如下:
par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 15")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 15)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 45")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 45)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 60")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 60)
效果图如下:

除了上面的针对arrows 的特殊参数之外,也支持一些通用的参数,col , lty ,lwd 等
代码如下:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, col = "red", lwd = 2, lty = 3)
效果图如下:

R语言低级绘图函数-arrows的更多相关文章
- R语言低级绘图函数-symbols
严格意义上将symbols 并不能算是一个低级的绘图函数,因为它不仅可以在一幅已经存在的图标上添加元素,还可以创建一张新的图表 鉴于它绘图时的灵活性,我把它归入到低级绘图函数中 symbols 可以创 ...
- R语言低级绘图函数-abline 转载
abline 函数的作用是在一张图表上添加直线, 可以是一条斜线,通过x或y轴的交点和斜率来确定位置:也可以是一条水平或者垂直的线,只需要指定与x轴或y轴交点的位置就可以了 常见用法: 1)添加直线 ...
- R语言低级绘图函数-grid
grid 函数用来在一张图表上添加网格线, 基本用法:默认在添加刻度线的地方添加网格线 plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = &qu ...
- R语言低级绘图函数-axis
axis函数用来在一张图表上添加轴线,区别于传统的x轴和y轴,axis 允许在上,下,左, 右4个方向添加轴线 以x轴为例,一条轴线包含3个元素,水平的一条横线,叫做axis line , 刻度线, ...
- R语言低级绘图函数-title
title 函数用来在一张图表上添加标题 基本用法: main 表示主标题,通常位于图像的上方, sub 表示副标题,位于图像的下方, xlab 表示x轴的标签,ylab 表示y轴的标签 par(om ...
- R语言低级绘图函数-text
text函数用来在一张图表上添加文字,只需要指定对应的x和y坐标,以及需要添加的文字内容就可以了 基本用法: plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), ...
- R语言低级绘图函数-rect
rect 函数用来在一张图上添加矩形,只需要指定左下角和右上角的坐标的位置,就可以画出一个矩形 基本用法: plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), ...
- R语言低级绘图函数-abline
abline 函数的作用是在一张图表上添加直线, 可以是一条斜线,通过x或y轴的交点和斜率来确定位置:也可以是一条水平或者垂直的线,只需要指定与x轴或y轴交点的位置就可以了 常见用法: 1)添加直线 ...
- R语言低级绘图函数画个温度计
x <- 1:2 y <- runif(2,0,100) par(mar=c(4,6,2,6)) plot(x,y,type="n",xlim=c(0.5,2.5),y ...
随机推荐
- ios 开源免费接口
ios 开源免费接口 国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather. ...
- OpenGl学习 SelectObject函数
SelectObject 函数功能:该函数选择一对象到指定的设备上下文环境中,该新对象替换先前的相同类型的对象. 函数原型:HGDIOBJ SelectObject(HDC hdc, HGDIOB ...
- mybatis 一二事(1) - 简单介绍
mybatis呢是一个orm数据库框架,非常适合新人学,门槛相对较低 本人呢曾经是先做的hibernate,后接触的mybatis,接触mabatis前我比较抵触,为啥呢, 当时喜欢hibernate ...
- express设置模板引擎
app.set('views', path.join(__dirname,'views')); app.set('view engine', 'ejs');
- HttpClient 教程 (一)
转自:http://www.cnblogs.com/loveyakamoz/archive/2011/07/21/2112804.html HttpClient 教程 (一) 前言 超文本传输协议 ...
- LeetCode: Substring with Concatenation of All Words 解题报告
Substring with Concatenation of All Words You are given a string, S, and a list of words, L, that ar ...
- Extjs 解决在IE 火狐浏览器字体太小问题
<style type="text/css"> *{font-size:12px!important;} </style>
- oozie中调度mapreduce
mapreduce可以直接对hdfs进行清洗和计算,这里介绍oozie中如何调度使用. 操作步骤如下: 1. 写一个mapper和reduce类,并且打包成jar包 2. 在workflow中引用ma ...
- oracle sql生成日历表
以下是生成2017年日历表: insert into dw_mdl.m_hadp_dim_date select to_char(everyDay,'yyyy-mm-dd') as dt, to_ch ...
- zoj3228 Searching the String AC自动机查询目标串中模式串出现次数(分可覆盖,不可覆盖两种情况)
/** 题目:zoj3228 Searching the String 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=34 ...