How To Add Text To a Plot in R @DataDaft
How To Add Text To a Plot in R  @DataDaft
Uploaded November 2020 | Updated November 2026, 2 hours ago
This video shows how to add text at arbitrary x, y positions to plots in base R and ggplot2.

If you find this video useful, like, share and subscribe to support the channel!

► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1


Code used in this R Code Clip:

# Add text to a base R plot

# Create plot
plot(mtcars$mpg, mtcars$hp)

# Add text at a given point
text(x = 22, # text x coordinate
y = 220, # text y coordinate
labels = "text", # text label
col = "purple", # text color
cex = 4) # text size


# Add text in ggplot
library(tidyverse)

ggplot(data = mtcars, aes(x = mpg, y = hp)) +
geom_point() + # Create scatterplot
annotate("text", x=22, y=220, # Add text
label = "text",
col = "purple",
size = 18)


* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones.
How To Add Text To a Plot in RHow to Select Rows Based on a Logical Condition in Pandas (Python)Python Programming Practice:  LeetCode #104   Maximum Depth of Binary TreeHow to Make a For Loop in PythonTop 15 MMA Fighters Over Time Ranked by Elo (1980-2020)Python Programming Practice: Leetcode #15   3SumPython for Data Analysis: Tuples and StringsPython Regex: How To Remove PunctuationHow to Access Rows by Name in Pandas (Python)Python Regex: How Find a Substring in a StringTwitter Trending This Week: USA (March 1- 8, 2020)Python for Data Analysis: Basic Math Operations
DataDaft |

How To Add Text To a Plot in R

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER