|
59 | 59 | fig, ax = plt.subplots() |
60 | 60 | im = ax.imshow(harvest) |
61 | 61 |
|
62 | | -# We want to show all ticks... |
63 | | -ax.set_xticks(np.arange(len(farmers))) |
64 | | -ax.set_yticks(np.arange(len(vegetables))) |
65 | | -# ... and label them with the respective list entries |
66 | | -ax.set_xticklabels(farmers) |
67 | | -ax.set_yticklabels(vegetables) |
| 62 | +# Show all ticks and label them with the respective list entries |
| 63 | +ax.set_xticks(np.arange(len(farmers)), labels=farmers) |
| 64 | +ax.set_yticks(np.arange(len(vegetables)), labels=vegetables) |
68 | 65 |
|
69 | 66 | # Rotate the tick labels and set their alignment. |
70 | 67 | plt.setp(ax.get_xticklabels(), rotation=45, ha="right", |
@@ -133,12 +130,9 @@ def heatmap(data, row_labels, col_labels, ax=None, |
133 | 130 | cbar = ax.figure.colorbar(im, ax=ax, **cbar_kw) |
134 | 131 | cbar.ax.set_ylabel(cbarlabel, rotation=-90, va="bottom") |
135 | 132 |
|
136 | | - # We want to show all ticks... |
137 | | - ax.set_xticks(np.arange(data.shape[1])) |
138 | | - ax.set_yticks(np.arange(data.shape[0])) |
139 | | - # ... and label them with the respective list entries. |
140 | | - ax.set_xticklabels(col_labels) |
141 | | - ax.set_yticklabels(row_labels) |
| 133 | + # Show all ticks and label them with the respective list entries. |
| 134 | + ax.set_xticks(np.arange(data.shape[1]), labels=col_labels) |
| 135 | + ax.set_yticks(np.arange(data.shape[0]), labels=row_labels) |
142 | 136 |
|
143 | 137 | # Let the horizontal axes labeling appear on top. |
144 | 138 | ax.tick_params(top=True, bottom=False, |
|
0 commit comments