日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

R语言低级绘图函数-axis

發(fā)布時(shí)間:2023/12/13 35 生活家
生活随笔 收集整理的這篇文章主要介紹了 R语言低级绘图函数-axis 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

axis函數(shù)用來在一張圖表上添加軸線,區(qū)別于傳統(tǒng)的x軸和y軸,axis 允許在上,下,左, 右4個(gè)方向添加軸線

以x軸為例,一條軸線包含3個(gè)元素,水平的一條橫線,叫做axis line , 刻度線, 叫做tick line, 對應(yīng)的標(biāo)簽 labels

基本用法:

通過side 參數(shù)設(shè)置需要添加的軸線的方向,從下邊開始,沿逆時(shí)針方向,數(shù)字為1到4

代碼示例:

par(oma = c(1, 1, 1, 1), mfrow = c(1, 4))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
text(x = 3, y = 3, labels = "side = 1", cex = 2)
box()
axis(side = 1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
text(x = 3, y = 3, labels = "side = 2", cex = 2)
box()
axis(side = 2)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
text(x = 3, y = 3, labels = "side = 3", cex = 2)
box()
axis(side = 3)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
text(x = 3, y = 3, labels = "side = 4", cex = 2)
box()
axis(side = 4)

效果圖如下:

參數(shù)設(shè)置:

at : 需要添加刻度的數(shù)值,默認(rèn)會(huì)根據(jù)變量的取值范圍計(jì)算幾個(gè)合適的刻度,也可以手工指定

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, at = c(0, 2, 4, 6))

效果圖如下:

lables : 指定在刻度上需要標(biāo)記的內(nèi)容,默認(rèn)就是刻度對應(yīng)的值

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, at = c(0, 2, 4, 6), labels = paste(c(0, 2, 4, 6), "A", sep = ""))

效果圖如下:

tick : 邏輯值,是否顯示軸線,包括刻度線和對應(yīng)的軸線, FALSE 表示不顯示

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
axis(side = 1, tick = F)

效果圖:

line : 軸線的位置

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1)

效果圖如下:

lwd : 設(shè)置 axis line 和 tick line 的寬度

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1, lwd = 2)

效果圖如下:

lwd.tick : 設(shè)置tick line的寬度

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1, lwd = 1, lwd.tick = 2)

效果圖如下:

lty : 設(shè)置axis line 和tick line的線條類型

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1, lty = 3)

效果圖如下:

col : 設(shè)置axis line 和 tick.line 的線條顏色

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1, col = "blue")

效果圖如下:

col.ticks : 設(shè)置tick line的顏色

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, line = 1, col = "blue", col.ticks = "red")

效果圖如下:

pos : 對軸線的位置進(jìn)行調(diào)整,當(dāng)pos 設(shè)置了對應(yīng)的值之后會(huì)覆蓋line 參數(shù)的值

代碼示例:

plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", axes = F)
box()
axis(side = 1, pos = 1)

效果圖如下:

總結(jié)

以上是生活随笔為你收集整理的R语言低级绘图函数-axis的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。