Draw polygon around scatterplot data?

Is there any package or combination of packages that would let me draw a polygon around a region in scatterplot data? Even just pieces I could cobble something together from.

The end goal is to use it to filter my points to do analyses on separate regions. I found Clipper.jl that does polygon arithmetic, just need a way to make the polygons that doesn’t make me want to die. I’m hoping I don’t have to go back to Matlab :slight_smile:

I think you are looking for a convex hull algorithm. I have not tried it but I think this should work: https://github.com/JuliaPolyhedra/ConvexHull.jl

1 Like

In Gadfly, you can make custom statistics. There are packages for convex hulls here: https://github.com/JuliaPolyhedra

Thanks, but I’m looking for something manual. There aren’t necessarily useful features to pick out the regions from the data alone. I need to manually draw a polygon around a visual of the data and then I’ll record the points I chose.

Then check out mouse events in makie

5 Likes

You could use a combination of keyboard and mouse events to pick points to create a polygon from, some control sequence (maybe Ctrl+M or something) to finish the polygon and mask, and then use (for example) Ctrl + U to unmask. From there, you could create a lines plot dependent on an Observable, and just update the observable on click.

1 Like

Thanks to you and mkborregaard! I found this post which I think gives me 90% of what I need: Makie based data labeling setup

I just need to figure out how to have a function wait for input and then return the array… I can get away with just clearing and repopulating a global if need be, but returning from a function would be nicer.

2 Likes