Skip to contents

Converts a ggplot2 plot to a Base64-encoded PNG image and returns an HTML img tag for embedding in a report.

Usage

plot2base64(
  plot,
  height,
  width = 7,
  base_height_per_row = 2.5,
  units = "in",
  html_img_width = "100%"
)

Arguments

plot

A ggplot2 plot object.

height

An integer specifying the height of the plot for correct representation in the HTML.

width

A numeric value specifying the width of the plot in inches.

base_height_per_row

A numeric value specifying the base height per row in inches.

units

A character string specifying the units for the width and height.

html_img_width

A character string specifying the width of the image in HTML.

Value

A character string containing an HTML img tag with the Base64-encoded plot.

See also