|
204 | 204 |
|
205 | 205 |
|
206 | 206 | def plot_color_gradients(cmap_category, cmap_list): |
| 207 | + # Create figure and adjust figure height to number of colormaps |
207 | 208 | nrows = len(cmap_list) |
208 | | - fig, axs = plt.subplots(nrows=nrows + 1, figsize=(6, 0.29 * nrows)) |
209 | | - fig.subplots_adjust(top=1, bottom=0, left=0.2, right=0.99) |
210 | | - axs[0].text(0.5, 0.5, cmap_category + " colormaps", fontsize=14, |
211 | | - transform=axs[0].transAxes, horizontalalignment="center", |
212 | | - verticalalignment="center") |
| 209 | + figh = 0.35 + 0.15 + (nrows + (nrows - 1) * 0.1) * 0.22 |
| 210 | + fig, axs = plt.subplots(nrows=nrows + 1, figsize=(6.4, figh)) |
| 211 | + fig.subplots_adjust(top=1 - 0.35 / figh, bottom=0.15 / figh, |
| 212 | + left=0.2, right=0.99) |
| 213 | + axs[0].set_title(cmap_category + ' colormaps', fontsize=14) |
213 | 214 |
|
214 | | - for ax, name in zip(axs[1:], cmap_list): |
| 215 | + for ax, name in zip(axs, cmap_list): |
215 | 216 | ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name)) |
216 | | - pos = list(ax.get_position().bounds) |
217 | | - x_text = pos[0] - 0.01 |
218 | | - y_text = pos[1] + pos[3]/2. |
219 | | - fig.text(x_text, y_text, name, va='center', ha='right', fontsize=10) |
| 217 | + ax.text(-0.01, 0.5, name, va='center', ha='right', fontsize=10, |
| 218 | + transform=ax.transAxes) |
220 | 219 |
|
221 | 220 | # Turn off *all* ticks & spines, not just the ones with colormaps. |
222 | 221 | for ax in axs: |
|
0 commit comments