Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit0b85e9b

Browse files
authored
Merge pull request#28642 from timhoffm/doc-heatmap
DOC: Simplify heatmap example
2 parentsf4f40ba +b7c3451 commit0b85e9b

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

‎galleries/examples/images_contours_and_fields/image_annotated_heatmap.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,9 @@
6363
im=ax.imshow(harvest)
6464

6565
# Show all ticks and label them with the respective list entries
66-
ax.set_xticks(np.arange(len(farmers)),labels=farmers)
67-
ax.set_yticks(np.arange(len(vegetables)),labels=vegetables)
68-
69-
# Rotate the tick labels and set their alignment.
70-
plt.setp(ax.get_xticklabels(),rotation=45,ha="right",
71-
rotation_mode="anchor")
66+
ax.set_xticks(range(len(farmers)),labels=farmers,
67+
rotation=45,ha="right",rotation_mode="anchor")
68+
ax.set_yticks(range(len(vegetables)),labels=vegetables)
7269

7370
# Loop over data dimensions and create text annotations.
7471
foriinrange(len(vegetables)):
@@ -137,17 +134,14 @@ def heatmap(data, row_labels, col_labels, ax=None,
137134
cbar.ax.set_ylabel(cbarlabel,rotation=-90,va="bottom")
138135

139136
# Show all ticks and label them with the respective list entries.
140-
ax.set_xticks(np.arange(data.shape[1]),labels=col_labels)
141-
ax.set_yticks(np.arange(data.shape[0]),labels=row_labels)
137+
ax.set_xticks(range(data.shape[1]),labels=col_labels,
138+
rotation=-30,ha="right",rotation_mode="anchor")
139+
ax.set_yticks(range(data.shape[0]),labels=row_labels)
142140

143141
# Let the horizontal axes labeling appear on top.
144142
ax.tick_params(top=True,bottom=False,
145143
labeltop=True,labelbottom=False)
146144

147-
# Rotate the tick labels and set their alignment.
148-
plt.setp(ax.get_xticklabels(),rotation=-30,ha="right",
149-
rotation_mode="anchor")
150-
151145
# Turn spines off and create white grid.
152146
ax.spines[:].set_visible(False)
153147

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp