日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

R语言:plot()函数参数合集

發布時間:2025/3/21 编程问答 62 豆豆
生活随笔 收集整理的這篇文章主要介紹了 R语言:plot()函数参数合集 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考: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將生成一條兩倍于默認寬度的線條

?(8)顏色

? ? 用于指定顏色的參數

  • col 默認的繪圖顏色。某些函數(如lines和pie)可以接受一個含有顏色值的向量并自動循環使用。例如,如果設定col=c("red", "blue")并需要繪制三條線,則第一條線將為紅色,第二條線為藍色,第三條線又將為紅色
  • col.axis 坐標軸刻度文字的顏色
  • col.lab 坐標軸標簽(名稱)的顏色
  • col.main 標題顏色
  • col.sub 副標題顏色
  • fg 圖形的前景色
  • bg 圖形的背景色

(9)字體

? ?用于指定文本大小的參數

  • 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(等寬)

(10)圖形尺寸和邊界尺寸

? ?用于控制圖形尺寸和邊界大小的參數

  • pin 以英寸表示的圖形尺寸(寬和高)
  • mai 以數值向量表示的邊界大小,順序為“下、左、上、右”,單位為英寸
  • mar 以數值向量表示的邊界大小,順序為“下、左、上、右”,單位為英分*。默認值為c(5, 4, 4, 2) + 0.1

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?

(11) 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()函数参数合集的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。