

Xlab="Weight", ylab="Mileage", pch=18, col="blue") The x, y, and label vectors should all be the same length. Specify location as a set of x, y coordinates and specify the text to place as a vector of labels. You can use the text( ) function (see above) for labeling point as well as for adding other text annotations. Other common options are cex, col, and font (for size, color, and font style respectively). you can also specify adj=0 for left/bottom alignment or adj=1 for top/right alignment.


you can specify line= to indicate the line in the margin starting with 0 and moving out. If you specify pos, you can specify offset= in percent of character width. Alternatively, the text can be placed interactively via mouse by specifying location as locator(1). (To practice adding text to plots in R, try this interactive exercise.) text( ) places text within the graph while mtext( ) places text in one of the four margins. Text can be added to graphs using the text( ) and mtext( ) functions. Many other graphical parameters (such as text size, font, rotation, and color) can also be specified in the title( ) function. Xlab=" x-axis label", ylab=" y-axis label") Title(main=" main title", sub=" sub-title", Use the title( ) function to add labels to a plot. Xlim=c( xmin, xmax), ylim=c( ymin, ymax))įor finer control or for modularization, you can use the functions described below. Xlab=" X-axis label", ylab=" y-axix label", Plot( x, y, main=" title", sub=" subtitle", Many high level plotting functions (plot, hist, boxplot, etc.) allow you to include axis and text options (as well as other graphical parameters).
