最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅。

plot(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
ann = par("ann"), axes = TRUE, frame.plot = axes,
panel.first = NULL, panel.last = NULL, asp = NA, ...)

plot 支持R 模块有:functions,data.frames,density,factor,table等常用结构。

plot参数:

(1)type类型

(2)xlim, x 用 (x1, x2) 限制 plot 的x 轴。同理,ylim,y 用(y1,y2)限制plot的y轴。

(3)main,给图片加标题.main="这是一幅图的标题".

或者

title("Main Title", sub = "sub title",
cex.main = 2, font.main= 4, col.main= "blue",
cex.sub = 0.75, font.sub = 3, col.sub = "red")

(4) xlab =“这是X轴表示什么”,ylab =“这是Y轴表示什么”

(5)axes指示是否两个坐标轴都画出。

(6) asp 限定 y/x aspect 比率

(7) points and lines

参数描述

pch 指定绘制点时使用的符号

cex 指定符号的大小。cex是一个数值,表示绘图符号相对于默认大小的缩放倍数。默认大小为1,1.5表示放大为默认值的1.5倍,0.5表示缩小为默认值的50%,等等

lty 指定线条类型

lwd 指定线条宽度。lwd是以默认值的相对大小来表示的(默认值为1)。例如,lwd=2将生成一条两倍于默认宽度的线条

(2)颜色

用于指定颜色的参数

col 默认的绘图颜色。某些函数(如lines和pie)可以接受一个含有颜色值的向量并自动循环使用。例如,如果设定col=c("red",
"blue")并需要绘制三条线,则第一条线将为红色,第二条线为蓝色,第三条线又将为红色

col.axis 坐标轴刻度文字的颜色

col.lab 坐标轴标签(名称)的颜色

col.main 标题颜色

col.sub 副标题颜色

fg 图形的前景色

bg 图形的背景色

(3)字体

用于指定文本大小的参数

cex 表示相对于默认大小缩放倍数的数值。默认大小为1,1.5表示放大为默认值的1.5倍,0.5表示缩小为默认值的50%,等等

cex.axis 坐标轴刻度文字的缩放倍数。类似于cex

cex.lab 坐标轴标签(名称)的缩放倍数。类似于cex

cex.main 标题的缩放倍数。类似于cex

cex.sub 副标题的缩放倍数。类似于cex

用于指定字体族、字号和字样的参数

font 整数。用于指定绘图使用的字体样式。1=常规,2=粗体,3=斜体,4=粗斜体,5=符号字体(以Adobe符号编码表示)

font.axis 坐标轴刻度文字的字体样式

font.lab 坐标轴标签(名称)的字体样式

font.main 标题的字体样式

font.sub 副标题的字体样式

ps 字体磅值(1磅约为1/72英寸)。文本的最终大小为 ps*cex

family 绘制文本时使用的字体族。标准的取值为serif(衬线)、sans(无衬线)和mono(等宽)

(4)图形尺寸和边界尺寸

用于控制图形尺寸和边界大小的参数

pin 以英寸表示的图形尺寸(宽和高)

mai 以数值向量表示的边界大小,顺序为“下、左、上、右”,单位为英寸

mar 以数值向量表示的边界大小,顺序为“下、左、上、右”,单位为英分*。默认值为c(5, 4, 4, 2) + 0.1

(8) Title,text,mtext

title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL,

line = NA, outer = FALSE, ...)
主要指定标题字体,大小,颜色,以及X和Y坐标轴的字体,大小,颜色。

main

The main title (on top) using font, size
(character expansion) and color par(c("font.main",
"cex.main", "col.main")).

sub

Sub-title (at bottom) using font, size
and color par(c("font.sub", "cex.sub",
"col.sub")).

xlab

X axis label using font, size and color par(c("font.lab",
"cex.lab", "col.lab")).

ylab

Y axis label, same font attributes as xlab.

line

specifying a value for line overrides
the default placement of labels, and places them this many lines outwards
from the plot edge.

outer

a logical value. If TRUE, the
titles are placed in the outer margins of the plot.

例如:title(main = list("Stopping Distance versus Speed", cex = 1.5,
                  col = "red", font = 3))
text(x, y = NULL, labels = seq_along(x$x), adj = NULL,
     pos = NULL, offset = 0.5, vfont = NULL,
     cex = 1, col = NULL, font = NULL, ...)

在给定X和Y的基础上插入一段注释,

Pos:a position specifier for the text. If specified this overrides any adj value given. Values of 1, 2, 3 and 4, respectively indicate positions below, to the left of, above and to the right of the specified coordinates.,1表示下方,2表示左方,3表示上方,4表示右方。

Labels: a character vector or expression specifying the text to be written. An attempt is made to coerce other language objects (names and calls) to expressions, and vectors and other classed objects to character vectors by as.character. If labels is longer than x and y, the coordinates are recycled to the length of labels.注释部分。

mtext(text, side = 3, line = 0, outer = FALSE, at = NA,
      adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...)

Text is written in one of the four margins of the current figure region or one of the outer margins of the device region。在作图的外围。

side

on which side of the plot (1=bottom, 2=left, 3=top, 4=right).

line

on which MARgin line, starting at 0 counting outwards.

Las:numeric in {0,1,2,3}; the style of axis labels. 标识坐标轴标签方向。

0:always parallel to the axis [default],

1:always horizontal,

2:always perpendicular to the axis,

3:always vertical.

R语言plot函数参数合集的更多相关文章

  1. R语言 plot()函数

    语法: plot(x, y, ...) x,y分别是两个向量,x为横轴坐标,y为纵轴坐标 其他参数: type= "p" for points, 散点图 默认 "l&qu ...

  2. R语言 plot()函数 基础用法

    plot(x=x轴数据,y=y轴数据,main="标题",sub="子标题",type="线型",xlab="x轴名称" ...

  3. Javascript 语言精粹 代码片段合集

    Javascript 语言精粹 代码片段合集 标签:Douglas-Crockford Javascript 最佳实践 原文链接 更好的阅读体验 使用一个method 方法定义新方法 Function ...

  4. 【R】R语言常用函数

    R语言常用函数 基本 一.数据管理vector:向量 numeric:数值型向量 logical:逻辑型向量character:字符型向量 list:列表 data.frame:数据框c:连接为向量或 ...

  5. R语言封装函数

    R语言封装函数 原帖见豆瓣:https://www.douban.com/note/279077707/ 一个完整的R函数,需要包括函数名称,函数声明,函数参数以及函数体几部分. 1. 函数名称,即要 ...

  6. shell中调用R语言并传入参数的两种步骤

    shell中调用R语言并传入参数的两种方法 第一种: Rscript myscript.R R脚本的输出 第二种: R CMD BATCH myscript.R # Check the output ...

  7. c语言中函数参数入栈的顺序是什么?为什么

    看到面试题C语言中函数参数的入栈顺序如何? 自己不知道,边上网找资料.下面是详细解释 #include <stdio.h> void foo(int x, int y, int z){   ...

  8. R语言table()函数

    R语言table()函数比较有用,两个示例尤其是混淆矩阵这个案例比较有用: 例子一:统计频次 z<-c(1,2,2,4,2,7,1,1);z1<-table(z);summary(z1); ...

  9. Matlab中plot函数参数解析

    功能 二维曲线绘图 语法 plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue, ...

随机推荐

  1. 去除input的默认样式

    input, button, select, textarea { outline: none; -webkit-appearance: none; border-radius: 0; } outli ...

  2. Centos7下PHP的卸载与安装nginx

    Centos7下PHP的卸载与安装nginx CentOS上PHP完全卸载,想把PHP卸载干净,直接用yum的remove命令是不行的,需要查看有多少rpm包,然后按照依赖顺序逐一卸载. 1.首先查看 ...

  3. bzoj1658: [Usaco2006 Mar]Water Slides 滑水

    Description It's a hot summer day, and Farmer John is letting Betsy go to the water park where she i ...

  4. 根据wsdl,axis2工具生成客户端代码

    根据wsdl,axis2工具生成客户端代码 步骤: 1,下载axis2版本http://axis.apache.org/axis2/java/core/download.html 2,下载完成后解压, ...

  5. FTP-FileZilla

    服务器上安装FileZilla Server连接时报You appear to be behind a NAT router. Please configure the passive mode se ...

  6. Python3基础 str format 四舍六入五凑偶 保留一位小数

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. linux下使用grep在当前目录下搜索所有文件中含有的字符串

    grep -r yourstr ./ 举例: grep -r sprintf ./ (在当前目录下递归查找含有字符串sprintf的文件)

  8. 【安装】Microsoft SQL Server的安装

    数据库版本:2012 系统环境:windows 7 一.安装 依次选择“安装->全新 SQL Server 独立安装或向现有安装添加功能”;点“确定” 选择版本,推荐标准版,这里是直接输入序列号 ...

  9. 论文笔记——ThiNet: A Filter Level Pruning Method for Deep Neural Network Compreesion

    论文地址:https://arxiv.org/abs/1707.06342 主要思想 选择一个channel的子集,然后让通过样本以后得到的误差最小(最小二乘),将裁剪问题转换成了优化问题. 这篇论文 ...

  10. WebForm、MVC、流式计算

    11月.NET技术讨论会圆满结束,会议纪要及相关文档如下如下:  1.WebForm预编译演示 文档:http://gitlab.light.fang.com/kongguDonet.Demo/Pre ...