0

The scatter function used to paint different data points that are actually full circles.

They can be of different sizes. The s parameter (to ax.scatter) contains the sizes of data points.

Form the documentation of matplotlib:

The marker size in points**2 (typographic points are 1/72 in.). Default is rcParams['lines.markersize'] ** 2.

To check distance between to points , I converted them to inches and then used :

 if (math.sqrt(allsizes[i]/3.14) + math.sqrt(allsizes[j])/3.14) > distance/72:
     print('overlap')

For some reason it almost works, but in cases of small overlap, it fails to find it. When it says there is overlap, there is overlap.

I am not sure if the sizes are R^2 or pi*R^2 , but none of these options seems to work. What did I do wrong?

Adding calculation:

def calc_distance(ax,x,y):
        diffy = abs(y[i] - y[j])
        diffx = abs(matplotlib.dates.date2num(x[i]) - matplotlib.dates.date2num(x[j]))
        origin = ax.figure.dpi_scale_trans.transform((0, 0))
        vec = ax.figure.dpi_scale_trans.transform((diffx, diffy))
        vec = np.array(vec) - np.array(origin)
        distance = np.linalg.norm(vec, ord=2)  # distange on display node
        return distance
user2679290
  • 144
  • 9

0 Answers0