詳解R語言plot函數(shù)參數(shù)合集
最近用R語言畫圖,plot 函數(shù)是用的最多的函數(shù),而他的參數(shù)非常繁多,由此總結(jié)一下,以供后續(xù)方便查閱。
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等常用結(jié)構(gòu)。
plot參數(shù):
(1)type類型

(2)xlim, x 用 (x1, x2) 限制 plot 的x 軸。同理,ylim,y 用(y1,y2)限制plot的y軸。
(3)main,給圖片加標(biāo)題.main="這是一幅圖的標(biāo)題".
或者
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指示是否兩個(gè)坐標(biāo)軸都畫出。
(6) asp 限定 y/x aspect 比率
(7) points and lines
參數(shù)描述
pch 指定繪制點(diǎn)時(shí)使用的符號(hào)

cex 指定符號(hào)的大小。cex是一個(gè)數(shù)值,表示繪圖符號(hào)相對(duì)于默認(rèn)大小的縮放倍數(shù)。默認(rèn)大小為1,1.5表示放大為默認(rèn)值的1.5倍,0.5表示縮小為默認(rèn)值的50%,等等
lty 指定線條類型

lwd 指定線條寬度。lwd是以默認(rèn)值的相對(duì)大小來表示的(默認(rèn)值為1)。例如,lwd=2將生成一條兩倍于默認(rèn)寬度的線條
(2)顏色
用于指定顏色的參數(shù)
col 默認(rèn)的繪圖顏色。某些函數(shù)(如lines和pie)可以接受一個(gè)含有顏色值的向量并自動(dòng)循環(huán)使用。例如,如果設(shè)定col=c("red", "blue")并需要繪制三條線,則第一條線將為紅色,第二條線為藍(lán)色,第三條線又將為紅色
col.axis 坐標(biāo)軸刻度文字的顏色
col.lab 坐標(biāo)軸標(biāo)簽(名稱)的顏色
col.main 標(biāo)題顏色
col.sub 副標(biāo)題顏色
fg 圖形的前景色
bg 圖形的背景色
(3)字體
用于指定文本大小的參數(shù)
cex 表示相對(duì)于默認(rèn)大小縮放倍數(shù)的數(shù)值。默認(rèn)大小為1,1.5表示放大為默認(rèn)值的1.5倍,0.5表示縮小為默認(rèn)值的50%,等等
cex.axis 坐標(biāo)軸刻度文字的縮放倍數(shù)。類似于cex
cex.lab 坐標(biāo)軸標(biāo)簽(名稱)的縮放倍數(shù)。類似于cex
cex.main 標(biāo)題的縮放倍數(shù)。類似于cex
cex.sub 副標(biāo)題的縮放倍數(shù)。類似于cex
用于指定字體族、字號(hào)和字樣的參數(shù)
font 整數(shù)。用于指定繪圖使用的字體樣式。1=常規(guī),2=粗體,3=斜體,4=粗斜體,5=符號(hào)字體(以Adobe符號(hào)編碼表示)
font.axis 坐標(biāo)軸刻度文字的字體樣式
font.lab 坐標(biāo)軸標(biāo)簽(名稱)的字體樣式
font.main 標(biāo)題的字體樣式
font.sub 副標(biāo)題的字體樣式
ps 字體磅值(1磅約為1/72英寸)。文本的最終大小為 ps*cex
family 繪制文本時(shí)使用的字體族。標(biāo)準(zhǔn)的取值為serif(襯線)、sans(無襯線)和mono(等寬)
(4)圖形尺寸和邊界尺寸
用于控制圖形尺寸和邊界大小的參數(shù)
pin 以英寸表示的圖形尺寸(寬和高)
mai 以數(shù)值向量表示的邊界大小,順序?yàn)椤跋?、左、上、右”,單位為英?/p>
mar 以數(shù)值向量表示的邊界大小,順序?yàn)椤跋?、左、上、右”,單位為英?。默認(rèn)值為c(5, 4, 4, 2) + 0.1

(8) Title,text,mtext
title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
line = NA, outer = FALSE, ...) 主要指定標(biāo)題字體,大小,顏色,以及X和Y坐標(biāo)軸的字體,大小,顏色。
|
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的基礎(chǔ)上插入一段注釋,
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. 標(biāo)識(shí)坐標(biāo)軸標(biāo)簽方向。
0:always parallel to the axis [default],
1:always horizontal,
2:always perpendicular to the axis,
3:always vertical.
到此這篇關(guān)于R語言plot函數(shù)參數(shù)合集的文章就介紹到這了,更多相關(guān)R語言plot函數(shù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用R語言繪制散點(diǎn)圖結(jié)合邊際分布圖教程
這篇文章主要介紹了使用R語言利用ggplot繪制散點(diǎn)圖,并且在圖像的兩邊繪制邊際分布圖(包括邊際直方圖與邊際密度函數(shù))我們這里介紹兩種方法進(jìn)行繪制2021-11-11
R繪制漂亮的中國(guó)地圖的實(shí)現(xiàn)示例
本文主要介紹了R繪制漂亮的中國(guó)地圖的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09

