Weighting function for a scatter plot of ratio and difference across several orders of magnitude

32 Views Asked by At

I am comparing straight line distances to the shortest discovered path. I have millions of points with a pair (straight line distance,shortest computed path) or (S,P) assigned to them. $0.0001 < S < 100$. $R=\frac{P}{S}$ and $D = P-S$

  1. Path is shorter than straight line ($R < 1$)
  2. Path is much longer than the straight line ($R >> 10$)

Small $D$ implies rounding errors and such cases are less interesting.

Example data

enter image description here

I am looking for a plot, possibly a scatter plot that would

  1. Work across several orders of magnitude
  2. Reveal cases with large $D$ and $R>>1$ or $R<1$ 3.$P$ and $S$ should be apparent from the plot

Scatter plot $log(R)$ vs $log(D)$ is attractive, but how to deal with negative $D$ values?

1

There are 1 best solutions below

1
On BEST ANSWER

symlog seems to be what you are looking for. This is an simple version in python

import pandas
import matplotlib.pyplot as plt

df = pandas.DataFrame([
    {'s' : 1, 'p' : 1.8},
    {'s' : 0.0004, 'p' : 0.0003},
    {'s' : 5, 'p' : 4},
    {'s' : 0.0001, 'p' : 0.0201},
    {'s' : 0.1, 'p' : 5}
])
df['r'] = df['p'] / df['s']
df['d'] = df['p'] - df['s']

plt.xscale('log')
plt.yscale('symlog')
plt.ylim(-20, 20)

plt.plot(df['r'], df['d'], '*', ms = 4)
plt.show()

enter image description here