filmov
tv
Plot Only Text in R (2 Examples) | Create Graphic in Base & ggplot2 | text() & annotate() Functions

Показать описание
R code of this video:
par(mar = c(0, 0, 0, 0)) # Remove white space around plot
plot(x = 0:1, # Create empty plot
y = 0:1,
ann = F,
bty = "n",
type = "n",
xaxt = "n",
yaxt = "n")
text(x = 0.5, # Add text to empty plot
y = 0.5,
"This is my first line of text!\nAnother line of text.\n(Created by Base R)",
cex = 1.8)
library("ggplot2") # Load ggplot2 package
ggplot() + # Draw ggplot2 plot with text only
annotate("text",
x = 1,
y = 1,
size = 8,
label = "This is my first line of text!\nAnother line of text.\n(Created by ggplot2)") +
theme_void()
Follow me on Social Media:
par(mar = c(0, 0, 0, 0)) # Remove white space around plot
plot(x = 0:1, # Create empty plot
y = 0:1,
ann = F,
bty = "n",
type = "n",
xaxt = "n",
yaxt = "n")
text(x = 0.5, # Add text to empty plot
y = 0.5,
"This is my first line of text!\nAnother line of text.\n(Created by Base R)",
cex = 1.8)
library("ggplot2") # Load ggplot2 package
ggplot() + # Draw ggplot2 plot with text only
annotate("text",
x = 1,
y = 1,
size = 8,
label = "This is my first line of text!\nAnother line of text.\n(Created by ggplot2)") +
theme_void()
Follow me on Social Media: