Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f9b9930

Browse filesBrowse files
committed
added solution from gallery/colormap reference
1 parent 630086a commit f9b9930
Copy full SHA for f9b9930

File tree

Expand file treeCollapse file tree

1 file changed

+9
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-10
lines changed

‎tutorials/colors/colormaps.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormaps.py
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,18 @@
204204

205205

206206
def plot_color_gradients(cmap_category, cmap_list):
207+
# Create figure and adjust figure height to number of colormaps
207208
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)
213214

214-
for ax, name in zip(axs[1:], cmap_list):
215+
for ax, name in zip(axs, cmap_list):
215216
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)
220219

221220
# Turn off *all* ticks & spines, not just the ones with colormaps.
222221
for ax in axs:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.