Open AAnzel opened 7 months ago
Thanks @AAnzel. Definitely would be nice to make this behavior as consistent as possible across all plot types. The history of this is that prior to plotly.js v2.13, all selections looked like what you see in polar. In 2.13 we added persistent selections, meaning that after you make a selection, if you zoom or pan the selection will still cover the same region of data space, and you can even create a plot with a predefined selection. Editing and dragging the selections came along with that new feature.
But we didn't extend this to polar (or ternary, all of what I'm about to say applies there as well except the shape distortion) because the main driver of this was persistence, and when you draw a rectangle on top of a polar plot the boundaries don't correspond to constant values in data space so they're hard to describe for persistence. Moreover if you zoom a polar plot, if the inner radius is not zero, the same selected area won't even be a rectangle.
Aside from the distortion, the same applies to ternary plots which also didn't get the upgraded selections.
Conceivably we could create editable & draggable selections on polar and ternary plots without making them persist to the layout... they would then need to disappear on zoom/pan (and probably on redraw too). Or we could alter the selection so you're not really drawing a box, but some shape aligned to the data coordinates - I guess a sector on polar plots and a triangle on ternary? That may be unintuitive to use though. Or we could try to come up with a way to describe rectangles in these spaces, and draw the distorted shapes if you zoom or pan. None of these seem like really great solutions to me, but any one of them would be a good deal of work. Which is why they didn't happen at the same time as cartesian selections.
I'm open to other suggestions for how this should behave!
Hello, @alexcjohnson ! Thank you for explaining the reasons behind the lack of this functionality and the associated difficulties. Based on my experience working with polar plots, I believe your last recommendation would be the most suitable for the proposed functionality. Drawing sectors on polar plots or triangles on ternary plots would align perfectly with the exploratory nature of the selection functionality.
Specifically, in the case of a polar plot, if we draw a sector using radial (similar to the current zoom implementation) and angular coordinates (not implemented), users would be able to move the created shape (in this case, a selection sector) across the polar space without distorting its shape. You can find an example of such a shape in red on this link. The same concept could be applied to the ternary plot.
Additionally, it's worth noting that polar and ternary coordinate spaces are not as commonly used as the Cartesian coordinate space, making them inherently less intuitive. However, I believe implementing a selection functionality would greatly improve data exploration in these spaces and bring them on par with other plot types in Plotly.
Thank you for starting this conversation, @AAnzel . Once we decide on the right way forward, would you be willing to take a shot at the pull request?
Hi @Coding-with-Adam! Sure thing, I would be more than happy to help. However, as I am not very proficient in JavaScript, I would prefer to work on the Python side of the implementation.
When using
Box Select
orLasso Select
from the Modebar for thescatter_polar
charts, the selection is not editable nor draggable as in regularscatter
charts. This can be easily verified by interacting with the charts from the official Plotly website:We should expect the same behavior across all charts available in Plotly.