add_labels: Add labels to a plotly scatter plot

View source: R/add_labels.R

add_labelsR Documentation

Add labels to a plotly scatter plot

Description

Adds labels to a plotly 2d or 3d scatter plot. The labels can be dragged.

Usage

add_labels(p, labs, plotGlPixelRatio = 8)

Arguments

p

A plotly scatter plot object

labs

Character vector of labels to match

plotGlPixelRatio

Integer passed to plotly.js config which controls pixel resolution of webGl rendering. Larger values increase resolution of points as well as file size.

Details

Labels are identified by searching the rownames of the embedded marker data within the plotly object. The plotly mode bar camera icon is set to export to svg by default.

Value

A plotly plot with added labels

Examples

library(plotly)
data(mtcars)

p <- plot_ly(mtcars, x = ~mpg, y = ~wt, color = ~cyl,
             type = 'scatter', mode = 'markers')
p %>% add_labels(c("Mazda RX4", "Fiat 128"))

easylabel documentation built on April 3, 2025, 6:22 p.m.