Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

smplot2 (version 0.2.5)

sm_add_text: Add a text annotation onto the combined plot

Description

Add a text annotation onto the combined plot

Usage

sm_add_text(
  label,
  x = 0.5,
  y = 0.5,
  angle = 0,
  color = "black",
  fontface = "plain",
  size = 10,
  ...
)

Value

Prints a text in the combined plot.

Arguments

label

Text label in strings.

x

Location of the text annotation along the x-axis of the combined figure. Default is the middle origin (0.5). Values from 0 to 1.

y

Location of the text annotation along the y-axis of the combined figure. Default is the middle origin (0.5). Values from 0 to 1.

angle

Angle of the text. Default is set to 0 (i.e., horizontal orientation).

color

Color of the text. Default is set to 'black'.

fontface

The default is to set the text as plain This can be changed, to either "plain", "bold", "italic", "bold.italic" .

size

Size of the text annotation

...

Other parameters of the text that will be transferred to the function annotate() from ggplot2.

Examples

Run this code
library(smplot2)
library(ggplot2)
ggplot(data = mtcars, mapping = aes(x = drat, y = mpg)) +
 geom_point(shape = 21, fill = '#0f993d', color = 'white',
            size = 3) -> p1

ggplot(data = mtcars, mapping = aes(x = drat, y = mpg)) +
 geom_point(shape = 21, fill = '#0f993d', color = 'white', size = 3) +
 sm_hvgrid() -> p2

combined_fig <- sm_put_together(list(p1,p2), ncol=2,nrow=1)
combined_fig + sm_add_text(label='My label', x = .5, y= .5)


Run the code above in your browser using DataLab