Skip to content

Instantly share code, notes, and snippets.

@aravindhebbali
Last active September 26, 2017 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aravindhebbali/7a445b32ca3a6e1f75e7d4bbf66cb702 to your computer and use it in GitHub Desktop.
Save aravindhebbali/7a445b32ca3a6e1f75e7d4bbf66cb702 to your computer and use it in GitHub Desktop.
Data Visualization: Text Annotations
# text inside plot
plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = 'Sample Text')
# color
plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = 'Sample Text', col = 'red')
# font
plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = 'Sample Text', col = 'red', font = 2)
# font family
plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = 'Sample Text', col = 'red', family = 'mono')
# font size
plot(mtcars$disp, mtcars$mpg)
text(x = 340, y = 30, labels = 'Sample Text', col = 'red', cex = 2)
# text on the margins
plot(mtcars$disp, mtcars$mpg)
mtext('Sample Text')
# specify margin
plot(mtcars$disp, mtcars$mpg)
mtext('Sample Text', side = 1)
# line
plot(mtcars$disp, mtcars$mpg)
mtext('Sample Text', line = 1)
# alignment
plot(mtcars$disp, mtcars$mpg)
mtext('Sample Text', adj = 0)
plot(mtcars$disp, mtcars$mpg)
mtext('Sample Text', adj = 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment