Skip to content

Commit 3cdcc5c

Browse files
committed
Finally fix delta plot ylims
So that perfectly uniform colormaps actually get a visible line
1 parent c05ba23 commit 3cdcc5c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

viscm/gui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,16 @@ def label(ax, s):
192192

193193
Jpapbp = self._sRGB1_to_uniform(RGB)
194194

195+
def delta_ymax(values):
196+
return max(np.max(values) * 1.1, 0)
197+
195198
ax = axes['deltas']
196199
local_deltas = N * np.sqrt(np.sum((Jpapbp[:-1, :] - Jpapbp[1:, :]) ** 2, axis=-1))
197200
print("perceptual delta peak-to-peak: %0.2f" % (np.ptp(local_deltas),))
198201
ax.plot(x[1:], local_deltas)
199202
arclength = np.sum(local_deltas) / N
200203
label(ax, "Perceptual deltas (total: %0.2f)" % (arclength,))
201-
ax.set_ylim(0, ax.get_ylim()[1])
204+
ax.set_ylim(-delta_ymax(-local_deltas), delta_ymax(local_deltas))
202205
ax.get_xaxis().set_visible(False)
203206

204207
ax = axes['cmap-greyscale']
@@ -215,6 +218,7 @@ def label(ax, s):
215218
"Perceptual lightness deltas (total: %0.2f)"
216219
% (np.sum(np.abs(lightness_deltas)) / N,))
217220
#ax.set_ylim(0, ax.get_ylim()[1])
221+
ax.set_ylim(-delta_ymax(-lightness_deltas), delta_ymax(lightness_deltas))
218222
ax.get_xaxis().set_visible(False)
219223

220224
# ax = axes['lightness']

0 commit comments

Comments
 (0)