- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add a citation in a plot created by using ggplot2 in R?
A footnote is generally used to give references to a document, text or image and it is called citation. It helps the reader or viewer to check out the original source using the new text or image is generated. If we want to give citation to a plot in R using ggplot2 package then we can add labs that has caption option to add the footnotes.
Example
Consider the below data frame −
> set.seed(1) > x<-rnorm(10,1.5) > y<-rnorm(10,2.5) > df<-data.frame(x,y) > df
Output
x y 1 0.8735462 4.0117812 2 1.6836433 2.8898432 3 0.6643714 1.8787594 4 3.0952808 0.2853001 5 1.8295078 3.6249309 6 0.6795316 2.4550664 7 1.9874291 2.4838097 8 2.2383247 3.4438362 9 2.0757814 3.3212212 10 1.1946116 3.0939013
Loading ggplot2 package and creating a scatterplot between x and y −
> library(ggplot2) > ggplot(df,aes(x,y))+geom_point()
Output
Creating the plot with footnote −
> ggplot(df,aes(x,y))+geom_point()+labs(caption="Correlation Analysis")
Output
- Related Articles
- How to add a horizontal line to the plot created by ggplot2 in R?
- How to highlight text inside a plot created by ggplot2 using a box in R?
- How to change legend values in a bar plot created by using ggplot2 in R?
- How to display regression slope using model in a plot created by ggplot2 in R?
- How to display regression intercept using model in a plot created by ggplot2 in R?
- How to extract data from a plot created by ggplot2 in R?
- How to align the text horizontally in a bar plot created by using ggplot2 in R?
- How to make all text size same in a plot created by using ggplot2 in R?
- How to add a mathematical expression in axis label in a plot created by using plot function in R?
- How to create horizontal line for a range of values in a plot created by using ggplot2 in R?
- How to remove the boxes around legend of a plot created by ggplot2 in R?
- How to change the angle of annotated text in plot created by using ggplot2 in R?
- How to add approximately equal sign in a plot using ggplot2 in R?
- How to save a plot as SVG created with ggplot2 in R?
- How to exclude extra margin between points and the axes for a plot created by using ggplot2 in R?

Advertisements