Change Font Size for Annotation using ggplot2 in R Last Updated : 03 Mar, 2021 Comments Improve Suggest changes Like Article Like Report ggplot2 is a data visualization package for the statistical programming language R. After analyzing and plotting graphs, we can add an annotation in our graph by annotate() function. This article discusses how the font size of an annotation can be changed with the annotation() function. Syntax: annotate() Parameters: geom : specify textx : x axis locationy : y axis locationlabel : custom textual contentcolor : color of textual contentsize : size of textfontface : fontface of textangle : angle of text By adding annotate function with only argument geom='text', it shows that ggplot knows that it has to add text, but it needs another parameter such as Location of text (x,y) and text data (label=text). Approach Import ggplot2Create/Import DatasetPlot the data on a graphAdd annotation() function with required parameters Let us first create a basic plot without annotating. Program : R # Import Package library(ggplot2) # df dataset df <- data.frame(a=c(2,4,8), b=c(5, 10, 15)) # plot graph plot = ggplot(df, aes(x = a, y = b)) + geom_point() + geom_line() # output plot Output: Basic Plot Now, Let us see how annotation can be added. Program : R # Import Package library(ggplot2) # df dataset df <- data.frame(a=c(2,4,8), b=c(5, 10, 15)) # plot graph plot = ggplot(df, aes(x = a, y = b)) + geom_point() + geom_line() plot + annotate('text', x = 6, y = 7.5, label = 'GeeksForGeeks', color='darkgreen') Output: label & color To change the size of the text, use the "size" argument. In the below example, the size of GeeksForGeeks is 10 and the color is red. Program : R # Import Package library(ggplot2) # df dataset df <- data.frame(a=c(2,4,8), b=c(5, 10, 15)) # plot graph plot = ggplot(df, aes(x = a, y = b)) + geom_point() + geom_line() plot + annotate('text', x = 6, y = 7.5, label = 'GeeksForGeeks', color='red', size = 10) Output: Size Comment More infoAdvertise with us Next Article Change Font Size for Annotation using ggplot2 in R I immortalishika2001 Follow Improve Article Tags : Technical Scripter R Language Technical Scripter 2020 R-ggplot Similar Reads How to change background color in R using ggplot2? In this article, we will discuss how to change the background color of a ggplot2 plot in R Programming Language. To do so first we will create a basic ggplot2 plot. Step 1: Create sample data for the plot. sample_data <- data.frame(x = 1:10, y = 1:10) Step 2: Load the package ggplot2. library("gg 2 min read Change the Background color of ggplot2 Text Label Annotation in R In this article, we will be looking at the approach to change the background color of ggplot2 text label Annotation in the R programming language. This can be done using the geom_label() function using its fill argument. The user needs to first install and import the ggplot2 package in the R console 1 min read Adjusting font size within a grob using textGrob() and ggplot2 In R graphics, particularly when combining multiple graphical objects grob (graphical object) is a fundamental building block for graphics in the grid package, which ggplot2 relies on for rendering plots. In this article, we will explore how to adjust font size using the textGrob() function, apply i 4 min read Changing Font Size and Direction of Axes Text in ggplot2 in R In this article, we will discuss how to change the font size and the direction of the axis text using the ggplot2 plot in R Programming language. For both of the requirement theme() function is employed. After plotting a regular graph, simply adding theme() with appropriate values will get the job d 2 min read Plot from DataFrame in ggplot2 using R ggplot2 is a popular data visualization library in the R programming language. It is widely used for creating beautiful, customizable, and informative visualizations. One of the most useful features of ggplot2 is the ability to plot data stored in a data frame. In this article, we will learn how to 4 min read Like