Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dot plot #25

Open
CAYdenberg opened this issue Jul 30, 2021 · 2 comments
Open

Dot plot #25

CAYdenberg opened this issue Jul 30, 2021 · 2 comments
Labels
enhancement New feature or request new chart type An enhancement that includes a new chart type

Comments

@CAYdenberg
Copy link
Owner

Examples: panels C, D, and E. The plotting is basically a scatter plot with a categorical X axis, but the dots need to "spread" on the X axis when they become clustered. Unknown: what is the algorithm for determining that spread?

CM-72-349-g002

@CAYdenberg CAYdenberg added enhancement New feature or request new chart type An enhancement that includes a new chart type labels Jul 30, 2021
@CAYdenberg
Copy link
Owner Author

Not sure yet how to implement the off-axis displacement, but terms for search engines include "beeswarm plot" and "jitter". One possible implementation is: https://observablehq.com/@d3/beeswarm

@CAYdenberg
Copy link
Owner Author

CAYdenberg commented Aug 4, 2021

Jitter algorithm:

  • Add two ChartStyle properties: jitterRadius and jitterMaxSpread.
  • A bin starts when two points are less than one jitter diameter apart
  • All of the points until the next point that is at least one jitter diameter apart are placed in the bin
  • The first point in the bin is the anchor: the next point is moved along the off-axis in the positive direction until it is a jitter diameter away
  • The second point is moved left along the off-axis in the negative direction until it is one jitter diameter away from the anchor
  • The third point is moved along the off-axis in the positive direction until it is one jitter diameter from the first point
  • continue moving even indexed points in the negative direction and odd indexed points in the positive direction
  • If any offset exceeds the jitterMaxSpread / 2, stop working on this bin. The next point begins a new bin. (Similarly if a point is more than 1 diameter away on the main axis, begin a new bin).
  • After all the offsets for a bin have been calculated, adjust the whole bin so that the total offset is 0. (In other words, if there are an even number of points, the anchor is moved left so the whole "weight" of the bin is even over the center line).
  • Possibly bins should alternate starting to the right and starting to the left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new chart type An enhancement that includes a new chart type
Projects
None yet
Development

No branches or pull requests

1 participant