Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 540c2b8

Browse files
committed
colormap title on extra axes
1 parent 5890283 commit 540c2b8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tutorials/colors/colormaps.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@
205205

206206

207207
def plot_color_gradients(cmap_category, cmap_list, nrows):
208-
fig, axs = plt.subplots(nrows=nrows, figsize=(6, 0.24 * nrows))
209-
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
210-
axs[0].set_title(cmap_category + ' colormaps', fontsize=14)
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")
211213

212-
for ax, name in zip(axs, cmap_list):
214+
for ax, name in zip(axs[1:], cmap_list):
213215
ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name))
214216
pos = list(ax.get_position().bounds)
215217
x_text = pos[0] - 0.01

0 commit comments

Comments
 (0)