Annotate Multiple Lines of Text to ggplot2 Plot in R Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to annotate Multiple Lines of text to ggplot2 Plot in R programming language. Let us first create a regular plot so that the difference is apparent, Example: R # Load Package library("ggplot2") # Create a DataFrame DF <- data.frame(X = runif(100, min=0, max=100), Y = runif(100, min=0, max=100)) # Create a ScatterPlot using ggplot2. ggplot(DF,aes(X, Y))+ geom_point(size = 5, fill = "green", color = "black", shape = 21) Output: ScatterPlot using ggplot2 Now to annotate multiple lines to the plot annotate() function is used along the regular plot. This function is passed the required value and attributes. The approach is similar to adding a single line to the plot, only difference being each new line should be created by using "\n" within the text that is to be passed to the plot. Syntax : annotate(geom, x, y, label) Parameters : geom : We assign geom that we want to add to the plot as a first parameter which will written in "" . geom can be anything like rect, segment, pointrange etc. here we will use text as a geom as we want to add text. all other arguments will be depends on geom that we select. So here all other parameters that we will use are only works for Annotating text to plot.x : Represents the Co-ordinates of X Axis.y : Represents the Co-ordinates of Y Axis.label : Text that we want to annotate on plot.Above threes parameters (i.e x, y and label) are necessary for annotating text but here we will also use two parameters size and color which are used to represent size and color of text respectively and they are not necessary to use. Return : Geoms on plot. Example: R # Load ggplot2 Package library("ggplot2") # Create a DataFrame for Plotting DF <- data.frame(X = runif(100, min=0, max=100), Y = runif(100, min=0, max=100)) # ScatterPlot with Multiple Lines Text on it. ggplot(DF,aes(X, Y))+ geom_point(size = 5, fill = "green", color = "black", shape = 21)+ annotate("text", x = 50, y = 10, label = "Geeks For Geeks\n(R Tutorial)", size = 10, color = "dark green") Output: ScatterPlot with Annotating Multiple Lines on Plot Comment More infoAdvertise with us Next Article How to create a plot using ggplot2 with Multiple Lines in R ? E erkrutikpatel Follow Improve Article Tags : R Language R-ggplot Similar Reads Annotate Text Outside of ggplot2 Plot in R Ggplot2 is based on the grammar of graphics, the idea that you can build every graph from the same few components: a data set, a set of geomsâvisual marks that represent data points, and a coordinate system. There are many scenarios where we need to annotate outside the plot area or specific area as 2 min read How to create a plot using ggplot2 with Multiple Lines in R ? In this article, we will discuss how to create a plot using ggplot2 with multiple lines in the R programming language. Method 1: Using geom_line() function In this approach to create a ggplot with multiple lines, the user need to first install and import the ggplot2 package in the R console and then 3 min read How to annotate a plot in ggplot2 in R ? In this article, we will discuss how to annotate functions in R Programming Language in ggplot2 and also read the use cases of annotate. What is annotate?An annotate function in R can help the readability of a plot. It allows adding text to a plot or highlighting a specific portion of the curve. Th 4 min read How to Combine Multiple ggplot2 Plots in R? In this article, we will discuss how to combine multiple ggplot2 plots in the R programming language. Combining multiple ggplot2 plots using '+' sign to the final plot In this method to combine multiple plots, here the user can add different types of plots or plots with different data to a single p 2 min read How to place plus minus operator in text annotation of plot (ggplot2)? In data visualization, adding text annotations can enhance the understanding of plots by providing additional information, such as statistical summaries. When dealing with statistics, the ± (plus-minus) operator is commonly used to denote a range, such as mean ± standard deviation. In ggplot2, you c 4 min read Add Bold and Italic text to ggplot2 Plot in R In this article, we will discuss how to add Bold and Italic Text to a plot using ggplot2 in the R Programming language. To add the bold and italic text we will be using the annotate() function from the ggplot2 library in R language, this function helps to add the text to the graph with different va 3 min read Like