Centring and Equally Spacing Jitter Points in a ggplot/violin plot

Please see photo.

Is there anyway to get the plotted points centred and more equally spaced within the shapes?

Using code;
ggplot(data,aes(x,y))+geom_violin()+geom_jitter(height=0,width=0.1)

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. In particular, it's hard to trouble shoot a question with data. Also, since the same question came up earlier today, please see homework policy.

See help(jitter) for more insight. What it tries to do is to distinguish points with nearby x,y coordinates by introducing a little noise.

Notice that applied here, it affects only the x\ axis. Each of the points has the same y value.

If we were to center the points on the mid-point of the violin, we'd no longer be using noise. To keep the discrimination, it's possible to make the point size smaller, so that jittering wouldn't be necessary, and then the points should be symmetrical about the intercept, unless they are identical. However, that will reduce legibility, which is self-defeating.

For these few data points, give consideration to whether a tabular presentation might be preferable to a plot. With fewer than 10 points in each object, there's not much to visualize.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.