3

I want to plot a hundred or so points on a world map. Some of the points are too close together, so I would like to be able to separate them, so that they are still approximately in the correct position, but not overlapping the neighbouring points.

Something like this might be useful in some cases, but in others it's going to make previously non-overlapping neighbours overlap.

Is there a nice way to do this in matplotlib, or will I have to manually code some kind of force-sprung separator before plotting?

naught101
  • 18,687
  • 19
  • 90
  • 138
  • Maybe answers to this question can help: https://stackoverflow.com/questions/8671808/matplotlib-avoiding-overlapping-datapoints-in-a-scatter-dot-beeswarm-plot – Shaido Jul 28 '17 at 06:48
  • To make it short, there is no built-in feature that spreads points in matplotlib. Writing your own algorithm that does it, or looking for similar problems online is necessary. The more of your efforts in finding a solution (either through writing code or through sharing your research) you show the higher the chances someone jumps in and provides help on the issue. – ImportanceOfBeingErnest Jul 28 '17 at 10:05
  • @Shaido: I don't want jitter. I want something deterministic, so that if e.g A and B are overlapping, they move away from their midpoint an equal distance. If three points are overlapping, they also move away from their midpoint proportionally to the amount of overlap, etc. – naught101 Jul 29 '17 at 08:38
  • @ImportanceOfBeingErnest: Yes, I know. I'm just aware of e.g. `position_dodge` in ggplot2, which does this, but only in one dimension, and I was wondering if there was something that already existed that I wasn't aware of. – naught101 Jul 29 '17 at 08:39

0 Answers0