1

I want to use plotly for interactive user-defined shapes.

I am aware this steps away from the graphics even though it remains in data-visualisation.

In my past work, I had used an xml file with the user defined shape, and had changed its color with the following code (attention, this is unfortunately not a self-contained example):

library(graphics)
library(grImport)
library(XML)
library(gridExtra)
library(jpeg)
library(png)
library(XML)

 doc <- xmlParse("shape.eps.xml")
 myDraw <- readPicture(saveXML(doc))

 node <- xpathSApply(doc, paste("//path[@id='", myDraw, "']/context/rgb", sep = ""))[[1]]
 rgbCol <- col2rgb(color)
 xmlAttrs(node)["r"] = rgbCol[1]/255

For now I will go with the superposition of rectangles, but as along as my shape can defined split in rectangles. Is there then a way to import and color user-defined shapes with plotly?

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
Xavier Prudent
  • 1,570
  • 3
  • 25
  • 54
  • Not sure if this is of interest, but you could let the user create and edit shapes interactively. Please see [this](https://stackoverflow.com/a/54777145/9841389) or [this](https://community.rstudio.com/t/draggging-multiple-points-using-plotly/22081/2) – ismirsehregal Jul 19 '22 at 14:22
  • Thanks, I did not know these possibilities. In my case I need a fixed pre-defined shape. – Xavier Prudent Jul 19 '22 at 14:28

0 Answers0