In a violin plot with a large number of samples, how close together the scattered points are gives you an alternative way of seeing the density, while also showing every point. But this doesn't work too well in sparser plots, because it can be that many points are plotted outside the outline of the violin plot. It would therefore be great to be able to scale the points in order to force them to lie inside the outline. You sometimes see "swarm plots" which are produced with a more refined version of this idea.
This can be achieved quite simply: when we call drawPoint, instead of drawing the point at x coordinate (for a vertical plot) props.x - props/width / 2 + random() * props.width, the random() component can be scaled by the estimate at v. (Which can in turn be interpolated from the nearest two points on the boundary that is calculated when the chart is created)
I'd be happy to do this, but I cannot for the life of me work out how to add a config option to anything that ends up available in _drawItems! If someone who actually understands TypeScript could explain that, I can bash the rest out.
In a violin plot with a large number of samples, how close together the scattered points are gives you an alternative way of seeing the density, while also showing every point. But this doesn't work too well in sparser plots, because it can be that many points are plotted outside the outline of the violin plot. It would therefore be great to be able to scale the points in order to force them to lie inside the outline. You sometimes see "swarm plots" which are produced with a more refined version of this idea.
This can be achieved quite simply: when we call
drawPoint, instead of drawing the point atxcoordinate (for a vertical plot)props.x - props/width / 2 + random() * props.width, therandom()component can be scaled by the estimate atv. (Which can in turn be interpolated from the nearest two points on the boundary that is calculated when the chart is created)I'd be happy to do this, but I cannot for the life of me work out how to add a config option to anything that ends up available in
_drawItems! If someone who actually understands TypeScript could explain that, I can bash the rest out.