The title function is used to add a caption to a chart
Basic usage:
Main represents the main title, usually above the image, sub for subtitle, below image, Xlab for x axis, Ylab for y-axis label
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 =" xl AB ", Ylab =" Ylab ")
As follows:
Parameter settings:
Col: Sets the color of the caption
CeX: Set the text size of the caption
Font: Formatting the text of a caption
The above three parameters can be set for different headings, it is important to note that Xlab and Ylab can not be set separately, can only be set at the same time, the corresponding parameters are Col.lab, Col.cex, Font.cex
code example:
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: Logical value, if true, places the caption outside the plot area
code example:
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 =" xl AB ", Ylab =" Ylab ", Outer=true)
As follows:
Expression is also allowed in title
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "N", Xlab = "", Ylab = "") title (main = Expression (sqrt (x)), SUB = exp Ression (x^2), Xlab = "Xlab", Ylab = "Ylab")
As follows:
For more information on expressions, refer to the Help documentation for the Plotmath function
R language Low-level drawing function-title