R語言 title()函數(shù)的參數(shù)用法說明
如下所示:
title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL, line = NA, outer = FALSE, ...)
| 參數(shù) | 描述 |
|---|---|
| main | 主標題 |
| sub | 副標題 |
| xlab | x軸標簽 |
| ylab | y軸標簽 |
| line | 到軸線的行數(shù)距離 |
| outer | 一個邏輯值。 如果為TRUE,則標題位于圖的外部邊緣. |
補充:R語言低級繪圖函數(shù)-title
title 函數(shù)用來在一張圖表上添加標題
基本用法:
main 表示主標題,通常位于圖像的上方, sub 表示副標題,位于圖像的下方, xlab 表示x軸的標簽,ylab 表示y軸的標簽
par(oma = c(1, 1, 1, 1)) plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", xlab = "", ylab = "") box(which = "figure", col = "red", lwd = 2) box(which = "plot", col = "blue", lwd = 2) title(main = "main tilte", sub = "sub title", xlab = "xlab", ylab = "ylab")
效果圖如下:

參數(shù)設置:
col : 設置標題的顏色
cex : 設置標題的文字大小
font : 設置標題的文字的格式
以上三個參數(shù)可以針對不同的標題分別進行設置,需要注意的是xlab和ylab 不能分開設置,只能是同時設置,對應的參數(shù)為 col.lab, col.cex, font.cex
代碼示例:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", xlab = "", ylab = "") title(main = "main tilte", sub = "sub title", xlab = "xlab", ylab = "ylab", col.main = "red", cex.sub = 1.5, col.lab = "blue")
效果圖:

outer : 邏輯值,如果為TRUE, 將標題放到plot area的外邊
代碼示例:
par(oma = c(5, 5, 3, 3)) plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", xlab = "", ylab = "") box(which = "figure", col = "red", lwd = 2) box(which = "plot", col = "blue", lwd = 2) title(main = "main tilte", sub = "sub title", xlab = "xlab", ylab = "ylab", outer=TRUE)
效果圖如下:

title 中也允許表達式
代碼示例:
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", xlab = "", ylab = "") title(main = expression(sqrt(x)), sub = expression(x^2), xlab = "xlab", ylab = "ylab")
效果圖如下:

更多關于表達式的書寫,可以參考plotmath 函數(shù)的幫助文檔
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。
相關文章
R語言中c()函數(shù)與paste()函數(shù)的區(qū)別說明
這篇文章主要介紹了R語言中c()函數(shù)與paste()函數(shù)的區(qū)別說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-04-04
R語言 title()函數(shù)的參數(shù)用法說明
這篇文章主要介紹了R語言 title()函數(shù)的參數(shù)用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-04-04
R語言數(shù)據(jù)類型與相應運算的實現(xiàn)
本文主要介紹了R語言數(shù)據(jù)類型與相應運算的實現(xiàn),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-03-03
R語言模擬疫情傳播圖RVirusBroadcast展示疫情數(shù)據(jù)
本文用RVirusBroadcast展示模擬的疫情數(shù)據(jù),讓R語言模擬疫情傳播圖來告訴你為什么還不到出門的時候,有需要的朋友可以借鑒參考下,希望能夠有所幫助2022-02-02

