Orange
library(plotly)
# 1. Criando a coluna com o texto exato exigido para o tooltip
Orange$tooltip <- paste0("Árvore ", Orange$Tree,
" — idade: ", Orange$age, " dias",
" — circ.: ", Orange$circumference, " mm")
# 2. Construindo o gráfico de linhas com Plotly
plot_ly(data = Orange,
x = ~age,
y = ~circumference,
color = ~Tree,
type = 'scatter',
mode = 'lines+markers', # lines+markers facilita passar o mouse
text = ~tooltip,
hoverinfo = 'text') %>%
layout(xaxis = list(title = 'Idade (dias)'),
yaxis = list(title = 'Circunferência (mm)'))