|
From: sfeam <sf...@us...> - 2015-09-16 15:56:33
|
On Wednesday, 16 September 2015 10:29:20 AM Tait wrote: > > Here is a direct comparison of the output using the swarm jitter > > and a random (normal distribution) displacement about x. > > > > http://skuld.bmsc.washington.edu/~merritt/gnuplot/violin.html > > At that zoom, the swarm jitter looks reasonable. There are two kinds > of "random" jitter, and I was not clear even with myself about which > one I meant where. A random offset indiscriminately applied to every > point, as you've shown in your example above, is still useful, but I > agree not as helpful as the swarm plot. I have updated that example to show uniform and Gaussian random jitter, and to show a kernel density plot for the same data. > > But going back to the zoom levels in > http://www.cbs.dtu.dk/~eklund/beeswarm/, what I'd want from a jitter > algorithm is that each point's offset from its original coordinate > is strictly the minimum offset necessary for that point to not > overlap its neighbors. That would eliminate the strings of points > getting increasingly large offsets just because the > immediately-preceeding point overlaps, when there's an open spot > closer to the central axis. It may be that the R code suffers from the symptom you describe, where points are drawn unnecessarily far from the center because of a nearest-neighbor effect. I have not found a rigorous description of how it works. The criterion I used for the gnuplot code is different. It is not "the immediately-preceding point overlaps". Rather it is 1) draw point N on the center line 2) count off how many of the subsequent points would overlap N if not jittered. Call this number j. 3) point N+1 is offset by 1 width, point N+2 is offset by -1 width point N+3 is offset by 2 widths, ... up to point N+j 4) N = N + J + 1 This new point is guaranteed not to overlap if drawn on the center line, so return to (1). A complicating factor is that the exact diameter of the point symbol in terms of plot x coordinates is dependent on the point symbol used, the terminal type, and the current zoom or plot scale. That is the motivation for the "spread" multiplier, which allows you to decrease the spacing if the program overestimates the point width or if the point shape permits closer spacing. E.g. if the delta-y value is greater than zero, an x-offset less than the circle radius can be sufficient to remove overlapping circles, but not squares. Ethan |