詳解R語(yǔ)言plot函數(shù)參數(shù)合集
最近用R語(yǔ)言畫(huà)圖,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類(lèi)型
(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)軸都畫(huà)出。
(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 指定線條類(lèi)型
lwd 指定線條寬度。lwd是以默認(rèn)值的相對(duì)大小來(lái)表示的(默認(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)簽(名稱(chēng))的顏色
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ù)。類(lèi)似于cex
cex.lab 坐標(biāo)軸標(biāo)簽(名稱(chēng))的縮放倍數(shù)。類(lèi)似于cex
cex.main 標(biāo)題的縮放倍數(shù)。類(lèi)似于cex
cex.sub 副標(biāo)題的縮放倍數(shù)。類(lèi)似于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)簽(名稱(chēng))的字體樣式
font.main 標(biāo)題的字體樣式
font.sub 副標(biāo)題的字體樣式
ps 字體磅值(1磅約為1/72英寸)。文本的最終大小為 ps*cex
family 繪制文本時(shí)使用的字體族。標(biāo)準(zhǔn)的取值為serif(襯線)、sans(無(wú)襯線)和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語(yǔ)言plot函數(shù)參數(shù)合集的文章就介紹到這了,更多相關(guān)R語(yǔ)言plot函數(shù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
R語(yǔ)言因子類(lèi)型的實(shí)現(xiàn)
本文主要介紹了R語(yǔ)言因子類(lèi)型的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03R語(yǔ)言 使用ggplot2繪制好看的分組散點(diǎn)圖
這篇文章主要介紹了R語(yǔ)言 使用ggplot2繪制好看的分組散點(diǎn)圖操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-04-04R語(yǔ)言中的vector(向量),array(數(shù)組)使用總結(jié)
這篇文章主要介紹了R語(yǔ)言中的vector(向量),array(數(shù)組)使用總結(jié),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03R語(yǔ)言基于Keras的MLP神經(jīng)網(wǎng)絡(luò)及環(huán)境搭建
這篇文章主要介紹了R語(yǔ)言基于Keras的MLP神經(jīng)網(wǎng)絡(luò),我并沒(méi)有使用python去對(duì)比結(jié)果,但NSS的文章中有做對(duì)比,數(shù)據(jù)顯示R與Python相比在各方面的差別都不大,具體內(nèi)容介紹跟隨小編一起看看吧2022-01-01解決R語(yǔ)言報(bào)錯(cuò):Error?in?y?+?1:non-numeric?argument?to?binary
R語(yǔ)言編程中的常見(jiàn)錯(cuò)誤有一些錯(cuò)誤是R的初學(xué)者和經(jīng)驗(yàn)豐富的R程序員都可能常犯的,下面這篇文章主要給大家介紹了關(guān)于解決R語(yǔ)言報(bào)錯(cuò):Error?in?y?+?1:non-numeric?argument?to?binary?operator的相關(guān)資料,需要的朋友可以參考下2022-11-11R語(yǔ)言學(xué)習(xí)之字符串和時(shí)間格式化詳解
這篇文章主要為大家詳細(xì)介紹了R語(yǔ)言中字符串和時(shí)間格式化的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-03-03R語(yǔ)言dplyr包之高效數(shù)據(jù)處理函數(shù)(filter、group_by、mutate、summarise)詳解
這篇文章主要介紹了R語(yǔ)言dplyr包之高效數(shù)據(jù)處理函數(shù)(filter、group_by、mutate、summarise)的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03