Skip to content

Commit 3fa9867

Browse files
committed
DOC: improvements from thoffman
1 parent b1492f9 commit 3fa9867

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

examples/images_contours_and_fields/image_antialiasing.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
constrained_layout=True)
9494
for ax, interp in zip(axs, ['nearest', 'antialiased']):
9595
pc = ax.imshow(a, interpolation=interp, cmap='RdBu_r', vmin=-1, vmax=1)
96-
ax.set_title(f"'{interp}'", fontsize='small')
96+
ax.set_title(f"'{interp}'")
9797
fig.colorbar(pc, ax=axs)
9898
plt.show()
9999

@@ -111,15 +111,23 @@
111111
a_rgba = cmap(norm(a))
112112
for ax, interp in zip(axs, ['nearest', 'antialiased']):
113113
pc = ax.imshow(a_rgba, interpolation=interp)
114-
ax.set_title(f"'{interp}'", fontsize='small')
114+
ax.set_title(f"'{interp}'")
115115
plt.show()
116116

117117
###############################################################################
118118
# A concrete example of where antialiasing in data space may not be desirable
119-
# is given here, where the anti-aliasing returns white pixels in data space,
120-
# and (imperceptible) purple pixels in RGBA space:
121-
122-
fig, axs = plt.subplots(1, 3, figsize=(5.5, 2), sharex=True, sharey=True,
119+
# is given here. The middle circle is all -1 (maps to blue), and the outer
120+
# large circle is all +1 (maps to red). Data anti-aliasing smooths the
121+
# large jumps from -1 to +1 and makes some zeros in between that map to white.
122+
# While this is an accurate smoothing of the data, it is not a perceptually
123+
# correct antialiasing of the border between red and blue. The RGBA
124+
# anti-aliasing smooths in colorspace instead, and creates some purple pixels
125+
# on the border between the two circles. While purple is not in the colormap,
126+
# it indeed makes the transition between the two circles look correct.
127+
# The same can be argued for the striped region, where the background fades to
128+
# purple rather than fading to white.
129+
130+
fig, axs = plt.subplots(1, 3, figsize=(5.5, 2.3), sharex=True, sharey=True,
123131
constrained_layout=True)
124132
f0 = 10
125133
k = 100

0 commit comments

Comments
 (0)