Map positive values to log10 for color, plus 1-2-5 decade colorbar ticks labelled with the ORIGINAL values (so the bulk variation is visible instead of being washed out by a few high-cost outliers).
(values)
| 94 | |
| 95 | |
| 96 | def log_color(values): |
| 97 | """Map positive values to log10 for color, plus 1-2-5 decade colorbar ticks |
| 98 | labelled with the ORIGINAL values (so the bulk variation is visible instead of |
| 99 | being washed out by a few high-cost outliers).""" |
| 100 | v = np.asarray(values, dtype=float) |
| 101 | vp = v[v > 0] |
| 102 | vmin = vp.min() if len(vp) else 1.0 |
| 103 | c = np.log10(np.clip(v, vmin, None)) |
| 104 | ticks = [m * 10.0 ** e for e in range(int(np.floor(np.log10(vmin))), int(np.ceil(np.log10(v.max()))) + 1) |
| 105 | for m in (1, 2, 5) if vmin <= m * 10.0 ** e <= v.max()] |
| 106 | return c, np.log10(ticks), ["{0:g}".format(t) for t in ticks] |
| 107 | |
| 108 | |
| 109 | def make_plotly(df, title, html_path, xcol, ycol, xlabel, ylabel, overlay): |