How to Add Names inside of the ggplot?

I would like to add my name inside of the plot. Any help will greatly appreciated!!

Thank you!!

A simple example:

library(ggplot2)
ggplot(mtcars, aes(cyl, disp)) + geom_point() + 
  geom_text(x = 4.5, y= 400, label = "My Name")

Created on 2019-09-21 by the reprex package (v0.2.1)

2 Likes

Thank you so much for quick response, It worked I appreciate your help.

I am using the below code and need modifications to the code to print my name

ggplot(data = dataset) + geom_point(mapping = aes(x=Age, y=EstimatedSalary, color=Purchased), stroke=2.0) + 
  ggtitle("Social Network Ads")

If you are asking for a specific recommendation for you data, I cannot say without knowing what the data are.

Have you considered using the subtitle argument of ggtitle()?

ggtitle("Social Network Ads", subtitle = "Your Name")

I am using Social_Network_ads dataset as shown below

image

I will guess at x and y values for the geom_text()

ggplot(data = dataset) + 
 geom_point(mapping = aes(x=Age, y=EstimatedSalary, color=Purchased), stroke=2.0) + 
 ggtitle("Social Network Ads") + geom_text(x = 25, y = 100000, label = "Your Name")
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.