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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

R语言低级绘图函数-axis

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

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

以x軸為例,一條軸線包含3個元素,水平的一條橫線,叫做axis line , 刻度線, 叫做tick line, 對應的標簽 labels

基本用法:

通過side 參數設置需要添加的軸線的方向,從下邊開始,沿逆時針方向,數字為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)

效果圖如下:

參數設置:

at : 需要添加刻度的數值,默認會根據變量的取值范圍計算幾個合適的刻度,也可以手工指定

代碼示例:

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 : 指定在刻度上需要標記的內容,默認就是刻度對應的值

代碼示例:

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 : 邏輯值,是否顯示軸線,包括刻度線和對應的軸線, 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 : 設置 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 : 設置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 : 設置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 : 設置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 : 設置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 : 對軸線的位置進行調整,當pos 設置了對應的值之后會覆蓋line 參數的值

代碼示例:

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

效果圖如下:

總結

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

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