R语言plot函数参数合集

最近用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.

 

来源:网络


智能推荐

pandas plot参数

封装matplotlib的plot函数 pandas.plot DataFrame.plot(x=None, y=None, kind=‘line’, ax=None, subplots=False, sharex=None, sharey=False, layout=None, figsize=None, use_index=True, title=None, grid=...

R语言中 layout函数

layout函数用于组合输出图,语法如下: 参数解释: mat:是矩阵,非0数字代表绘制图形的顺序,相同数字代表占位符;”0”代表空缺,不绘制图形; widths = rep.int(1, ncol(mat))各列宽度,与heights = rep.int(1, nrow(mat))各行高度,从下面例子理解; respect:逻辑值或矩阵,矩阵的话必须与mat维度一致,矩阵...

R语言paste函数解析

一、paste函数 paste (..., sep = " ", collapse = NULL) paste0(..., collapse = NULL) paste converts its arguments (via as.character) to character strings, and concatenates them (separating them by...

R语言常用函数par()

转载于:https://baijiahao.baidu.com/s?id=1608788822798459472 par函数概述 在R绘图时,有时我们想在一个绘图区中同时绘制多幅图。在R语言中可以有多个函数来实现此要求。这里先介绍一下绘图参数par函数的使用。 R中的par()函数可以将绘图区分割成规则的几个部分。 多图环境用参数mfrow或参数mfcol来设定,如: par(mforw=c(3,...

R语言函数总结(转)

    R语言特征 对大小写敏感 通常,数字,字母,. 和 _都是允许的(在一些国家还包括重音字母)。不过,一个命名必须以 . 或者字母开头,并且如果以 . 开头,第二个字符不允许是数字。 基本命令要么是表达式(expressions)要么就是 赋值(assignments)。 命令可以被 (;)隔开,或者另起一行。 基本命令可以通过大括弧({和}) 放在一起构成一个复合表达式...

猜你喜欢

vuejs项目:路由跳转时更改页面title - 代码篇

文章目录 (含效果图、演示代码)vue路由跳转不同页面的时候,自动更改页面title 一、效果图演示: 二、示例 · 重要代码: 三、设置总结 (含效果图、演示代码)vue路由跳转不同页面的时候,自动更改页面title 一、效果图演示: 二、示例 · 重要代码: 三、设置总结 router文件夹下的index.js文件中给每个path添加meta:{ }; (具体参考下...

Cortex-M3权威指南阅读笔记1

1.基本概念 ARM的体系架构版本:即其所使用的指令集的版本。ARM架构支持32位ARM指令集和16位Thumb指令集,后者使代码存储空间大大减小并提供一些拓展功能(Jazelle、Trustzone、IEM等)。 架构有ARMv4、ARMv4T、ARMv5TEJ、ARMv6、ARMv9等等。相同的指令集下,搭配不同的部件即为不同的处理器:ARM7、ARM9、Cortex、SecurCore等系列...

maven打包多环境

参考https://blog.csdn.net/liudongdong0909/article/details/62891602 mvn clean package -P test -----> 测试环境 mvn clean package -P dev -----> 开发环境 或者 mvn -P test install mvn -P test package...

EKF

Extended Kalman Filter (EKF) EKF2 和 EKF3 的优缺点 EKF2被默认最稳定 EKF2能接收从Vicon系统或者ROS SLAM 中接受位置估计,EKF3目前是没有的,除非和EKF2一样。 EKF2仅仅估计加速度z轴补偿,EKF3估计三轴加速度补偿。 EKF3接收更新的传感器源,包括:Beacons、Wheel Encoders 以及Visual Odometr...

计算机网络概论

计算机网络概论 定义 简单定义 ​ 计算机网络是以能够相互共享资源的方式互连起来的自治计算机系统的集合。 较好的定义 ​ 计算机网络主要是由一些通用的、可编程的硬件互连而成的,而这些硬件并非专门用来实现某一特定目的(例如,传送数据或视频信号)。这些可编程的硬件能够用来传送多种不同类型的数据,并能支持广泛的和日益增长的应用。 计算机网络组成 从物理组成来看 ​ 1) 硬件:由主机、通信处理机(或称为...

问答精选

The union of two determinstic finite automata?

I'm trying to solve a problem where I have to create a DFA for the union of two languages. These are: {s is {a, b, c}*| every "a" in s is immediately followed by a "b"} and { s is ...

Console output omitted when using commas instead of "\n"

I can't explain myself the following weird behaviour: In the inOrder() function, if I write printf("%d\n", node->value) (hence with "\n")everything works fine and the program gi...

PyQt - questions about QSlider and QGraphicsTextItem

I'm totally stuck with 2 problems: 1) i'm using QSlider to set some values (they're float ~0.5, so i'm using *1000). SingleStep and PageStep work fine for keyboard input and mouse wheel, ticks're all ...

set jquery default animation speed

I cannot find any documentation. All I want to do it set jQuerys default animation speed. Something like this: Thanks folks! or Reference: https://learn.jquery.com/effects/intro-to-effects/#jquery-fx...

Android - Using AutoCompleteTextView to detect a word next to `@`

Firstly, I am really new in AutoCompleteTextView, and as can be inferred from the title, I want to use it to Tag people in the social media app I am currently developing. First I've created a class na...

相关问题

相关文章

热门文章

推荐文章

相关标签

推荐问答