R语言低级绘图函数-rect
rect 函数用来在一张图上添加矩形,只需要指定左下角和右上角的坐标的位置,就可以画出一个矩形
基本用法:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5)
效果图如下:

xleft, ybottom, xright, ytop 支持一次设置多个值,同时创建多个矩形,用法如下:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = c(1, 2), ybottom = c(1, 2), xright = c(5, 4), ytop = c(5, 4))
效果图如下:

参数设置:
border : 设置矩形边框的颜色,默认为"black", 支持为多个矩形设置不同的值
代码示例:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = c(1, 2), ybottom = c(1, 2), xright = c(5, 4), ytop = c(5, 4), border = c("red", "blue"))
效果图如下:

col : 设置矩形的填充色,默认为NULL, 表示无填充色,, 支持为多个矩形设置不同的值
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = c(1, 2), ybottom = c(1, 2), xright = c(5, 4), ytop = c(5, 4), col = c("pink", "green"))
效果图如下:

density 和 angle : 搭配使用,设置用线条填充矩形,angle 设置线条的角度,默认为45, density 设置填充线条的密度,数值越大越密集
代码示例:
par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "density = 1")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5, angle = 45, density = 1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "density = 3")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5, angle = 45, density = 2)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "density = 4")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5, angle = 45, density = 3)
效果图如下:

lwd: 设置矩形所有线条的宽度
代码示例:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5, angle = 45, density = 2, lwd = 3)
效果图如下:

lty: 设置矩形所有线条的类型
代码示例:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
rect(xleft = 1, ybottom = 1, xright = 5, ytop = 5, angle = 45, density = 2, lwd = 2, lty = 3)
效果图如下:

R语言低级绘图函数-rect的更多相关文章
- 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语言低级绘图函数-arrows
arrows 函数用来在一张图表上添加箭头,只需要分别指定起始坐标和终止坐标,就可以添加箭头了,还可以通过一些属性对箭头的形状,大小进行调整 基本用法: xo, yo 指定起始点的x和y坐标,x1, ...
- 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 ...
随机推荐
- unity 在Game视图中显示Gizmos
自己画的Gizmos要想在Game视图中能看到,需要把Game视图窗口右上角的"Gizmos"按钮点下去.如图: 比如,下面代码以角色的capsuleCollider中心为中心画一 ...
- unity5 Edit Collider
按下Edit Collider按钮,视图中Collider线框中出现控制点,可以通过拖动控制点对Collider进行调整.
- Windows 上安装docker
Windows 上安装docker //(第一种)下载boot2docker https://github.com/boot2docker/windows-installer/releases //( ...
- extjs中组件监听器里面的回调函数说明
近期在看项目源代码的时候发现了例如以下代码,当中_searchSupplierStore是JsonStore对象 _searchSupplierStore.on('beforeload',functi ...
- ajax 兼容性问题解决 集锦
这两天刚解决了ajax多浏览器兼容的问题,主要就针对Firefox的,开始还以为Firefox不支持ajax呢(别笑我呀,不怎么了解Firefox也没用过,呵呵),多亏看了下面的文章才让我了解ajax ...
- css实现遮罩层(解决透明背景上的文字不透明)
.PopUp_layer{ position:fixed; top: 0; left: 0; right:0; bottom:0; width:100%; height:1 ...
- LeetCode 新题: Find Minimum in Rotated Sorted Array 解题报告-二分法模板解法
Find Minimum in Rotated Sorted Array Question Solution Suppose a sorted array is rotated at some piv ...
- LeetCode: Candy 解题报告
Candy There are N children standing in a line. Each child is assigned a rating value. You are giving ...
- C# 回调与 javascritp 回调 比较
C#: using System; using System.Collections.Generic; using System.Text; namespace Delegate { //定义委托,它 ...
- hive 进阶笔记
-- mysql方式 create table account_channel(account_ String,channel_ String) as select a.account,b.chann ...