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 Smooth data for a geom_area graph Using ggplot2 in R The ggplot2 package is a powerful and widely used package for graphic visualization. It can be used to provide a lot of aesthetic mappings to the plotted graphs. This package is widely available in R. The package can be downloaded and installed into the working space using the following command : in 3 min read Change Font Size of ggplot2 Facet Grid Labels in R In this article, we will see how to change font size of ggplot2 Facet Grid Labels in R Programming Language. Let us first draw a regular plot without any changes so that the difference is apparent. Example: R library("ggplot2") DF <- data.frame(X = rnorm(20), Y = rnorm(20), group = c("Label 1", 2 min read Change Color of ggplot2 Boxplot in R In this article, we are going to see how to change the color of boxplots using ggplot2 in R Programming Language. We have considered the built-in data frame "ChickWeight". It contains information about the feed type and growth rate of chickens for six different types of foods like casein, soybean, 3 min read How to change plot area margins using ggplot2 in R? In the R programming language, ggplot2 is a popular library for creating data visualizations. One of the key benefits of using ggplot2 is the ability to customize the appearance of plots in a variety of ways. In this article, we will explore some of the ways you can customize the appearance of your 3 min read Change Space and Width of Bars in ggplot2 Barplot in R In this article, we will see how to change the Space and width of bars in ggplot2 barplot in R. For Create a simple Barplot using ggplot2, first we have to load the ggplot2 package using the library() function. If you have not already installed then you can install it by writing the below command i 4 min read Like