plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Add interactivity for geom_pcp

Open dicook opened this issue 5 months ago • 0 comments

It would be elegant to be able to create interactive parallel coordinate plots with plotly layered on the ggpcp library. Users should be able to select a line (or lines) and the entire line would highlight.

library(ggplot2)
data(mtcars)
mtcars_pcp <- mtcars |>
  dplyr::mutate(
    cyl = factor(cyl),
    vs = factor(vs),
    am = factor(am),
    gear = factor(gear),
    carb = factor(carb)
  ) |>
  pcp_select(1:11) |>  # select everything
  pcp_scale() |>
  pcp_arrange()

 base <- mtcars_pcp |> ggplot(aes_pcp())


 # Just the base plot:
 base + geom_pcp()

# Ideally this would allow lines to be selected 
ggplotly() 

# Or something like:
highlight_key(mtcars) |> ... (ggplot2 code) |> ggplotly()

dicook avatar Sep 08 '24 22:09 dicook