|
93 | 93 | constrained_layout=True)
|
94 | 94 | for ax, interp in zip(axs, ['nearest', 'antialiased']):
|
95 | 95 | 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}'") |
97 | 97 | fig.colorbar(pc, ax=axs)
|
98 | 98 | plt.show()
|
99 | 99 |
|
|
111 | 111 | a_rgba = cmap(norm(a))
|
112 | 112 | for ax, interp in zip(axs, ['nearest', 'antialiased']):
|
113 | 113 | pc = ax.imshow(a_rgba, interpolation=interp)
|
114 |
| - ax.set_title(f"'{interp}'", fontsize='small') |
| 114 | + ax.set_title(f"'{interp}'") |
115 | 115 | plt.show()
|
116 | 116 |
|
117 | 117 | ###############################################################################
|
118 | 118 | # 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, |
123 | 131 | constrained_layout=True)
|
124 | 132 | f0 = 10
|
125 | 133 | k = 100
|
|
0 commit comments