Andras Farkas
2020-Dec-10 20:57 UTC
[R] plotly: ability to drag points on x axis only and prevent change of y axis value
Hello, wonder if you could provide input on the following: please see toy example below, wanted to see if there is a way to have restrictions on how the points are dragged on the plot. More specifically I would like the points draggable horizontally ONLY and have their y axis value remain fixed, ie the movement vertically would be restricted and no change allowed to that direction for each point? much appreciate any input you may have, library(plotly) library(purrr) # creates a list of 32 circle shapes (one for each row/car) circles <- map2( ? mtcars$mpg,? ? mtcars$wt,? ? ~list( ? ? type = "circle", ? ? # anchor circles at (mpg, wt) ? ? xanchor = .x, ? ? yanchor = .y, ? ? # give each circle a 2 pixel diameter ? ? x0 = -5, x1 = 5, ? ? y0 = -5, y1 = 5, ? ? xsizemode = "pixel",? ? ? ysizemode = "pixel", ? ? # other visual properties ? ? fillcolor = "blue", ? ? line = list(color = "transparent") ? ) ) plot_ly() %>% ? layout(shapes = circles) %>% ? config(edits = list(shapePosition = TRUE)) appreciate the help, thanks, Andras?