R語(yǔ)言使用plot函數(shù)可視化數(shù)據(jù)、使用type參數(shù)自定義設(shè)置可視化的類型(數(shù)據(jù)點(diǎn)和線關(guān)系的類型)、設(shè)置type參數(shù)為p只有數(shù)據(jù)點(diǎn)沒(méi)有線條

R語(yǔ)言使用plot函數(shù)可視化數(shù)據(jù)、使用type參數(shù)自定義設(shè)置可視化的類型(數(shù)據(jù)點(diǎn)和線關(guān)系的類型)、設(shè)置type參數(shù)為p只有數(shù)據(jù)點(diǎn)沒(méi)有線條


R 是一個(gè)有著統(tǒng)計(jì)分析功能及強(qiáng)大作圖功能的軟件系統(tǒng),是由奧克蘭大學(xué)統(tǒng)計(jì)學(xué)系的Ross Ihaka 和 Robert Gentleman 共同創(chuàng)立。由于R 受Becker, Chambers & Wilks 創(chuàng)立的S 和Sussman 的Scheme 兩種語(yǔ)言的影響,所以R 看起來(lái)和S 語(yǔ)言非常相似。

R語(yǔ)言被稱作R的部分是因?yàn)閮晌籖 的作者(Robert Gentleman 和Ross Ihaka) 的姓名,部分是受到了貝爾實(shí)驗(yàn)室S 語(yǔ)言的影響(稱其為S 語(yǔ)言的方言)。

R 語(yǔ)言是為數(shù)學(xué)研究工作者設(shè)計(jì)的一種數(shù)學(xué)編程語(yǔ)言,主要用于統(tǒng)計(jì)分析、繪圖、數(shù)據(jù)挖掘。

R語(yǔ)言原生plot函數(shù)能夠滿足基礎(chǔ)可視化的絕大部分功能;

Function and argumentsOutput plot

plot(x, y)數(shù)值向量的散點(diǎn)圖、Scatterplot of x and y numeric vectors

plot(factor)因子變量的柱狀圖、Barplot of the factor

plot(factor, y)數(shù)據(jù)變量的箱圖;Boxplot of the numeric vector

and the levels of the factor

plot(time_series)時(shí)間序列圖、Time series plot

plot(data_frame)dataframe中數(shù)據(jù)的相關(guān)性圖;Correlation plot of all

dataframe columns

(more than two columns)

plot(date, y)可視化日期向量;Plots a date-based vector

plot(function, lower, upper)可視化函數(shù)的曲線;Plot of the function between the lower

and maximum value specified

plot函數(shù)中type參數(shù)的常用值;

Plot typeDescription

p數(shù)據(jù)點(diǎn);Points plot (default)

l線圖;Line plot

b點(diǎn)和線;Both (points and line)

o點(diǎn)和線、連接起來(lái)的;Both (overplotted)

s階梯;Stairs plot

h類似直方圖;Histogram-like plot

n不顯示;No plotting

仿真數(shù)據(jù)

set.seed(123)

# Generate sample data

x <- rnorm(500)

y <- x + rnorm(500)

# Data

my_ts <- ts(matrix(rnorm(500), nrow = 500, ncol = 1),

? ? ? ? ? ? ? start = c(1950, 1), frequency = 12)

my_dates <- seq(as.Date("2005/1/1"), by = "month", length = 50)

my_factor <- factor(mtcars$cyl)

fun <- function(x) x^2

?R語(yǔ)言使用plot函數(shù)可視化數(shù)據(jù)、使用type參數(shù)自定義設(shè)置可視化的類型(數(shù)據(jù)點(diǎn)和線關(guān)系的類型)、設(shè)置type參數(shù)為p只有數(shù)據(jù)點(diǎn)沒(méi)有線條

j <- 1:20

k <- j

par(mfrow = c(1, 3))

plot(j, k, type = "l", main = "type = 'l'")

plot(j, k, type = "s", main = "type = 's'")

plot(j, k, type = "p", main = "type = 'p'")

par(mfrow = c(1, 1))

par(mfrow = c(1, 3))

plot(j, k, type = "l", main = "type = 'o'")

plot(j, k, type = "s", main = "type = 'b'")

plot(j, k, type = "p", main = "type = 'h'")

par(mfrow = c(1, 1))

安利一個(gè)R語(yǔ)言的優(yōu)秀博主及其CSDN專欄:

博主博客地址:

博主R語(yǔ)言專欄地址(R語(yǔ)言從入門到機(jī)器學(xué)習(xí)、持續(xù)輸出已經(jīng)超過(guò)1000篇文章)

參考:R

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容