Text is defined as way to describe data related to graphical representation. They work as a labels to any pictorial or graphical representation. In this article we will learn to to add a text to a plot in R Language by using the
Syntax: text(x, y, labels)
x and y: numeric values specifying the coordinates of the text to plot
labels: the text to be written
Returns: Added text to plot
In above example, the text is added to plot of ‘mtcar’ dataset.
Example 2: Implementation of text() to add mathematical annotation to a plot
In above example the the
text() function is used to add mathematical annotation to a plot
Add text to the margins of the graph
mtext() function is used to add text to the margins of the plot.
Syntax: mtext(text, side)
text: text to be written
side: An integer specifying the side of the plot, such as: bottom, left, top, and right.
Returns: Added text in the margins of the graph
Here, in above example the side specifies the side of the plot such as bottom, left, top, right . And in the given the side=3 i.e the top part of the plot