Skip to content

Commit d2e686f

Browse files
authored
Merge pull request #47 from histogrammar/heatmap_vis_fix
FIX: show edge of heatmap for categorical histograms
2 parents dd3be58 + 986eb5e commit d2e686f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

histogrammar/plot/matplotlib.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -757,16 +757,20 @@ def tick(lab):
757757
y_labels = [tick(lab) for lab in y_labels]
758758

759759
# plot 2d grid
760+
xedges = np.arange(len(x_labels) + 1)
761+
yedges = np.arange(len(y_labels) + 1)
762+
760763
xtick_pos = np.arange(len(x_labels)) + 0.5
761764
ytick_pos = np.arange(len(y_labels)) + 0.5
762765

763-
im = ax.pcolormesh(xtick_pos, ytick_pos, grid, shading='auto', **kwargs)
766+
# always needs egdes, so one more than grid length
767+
im = ax.pcolormesh(xedges, yedges, grid, shading='auto', **kwargs)
764768
fig.colorbar(im, ax=ax)
765769

766-
ax.set_xlim((0., float(len(x_labels))))
767-
ax.set_ylim((0., float(len(y_labels))))
768770
ax.set_xticks(xtick_pos)
769771
ax.set_yticks(ytick_pos)
772+
ax.set_xlim((0., float(len(x_labels))))
773+
ax.set_ylim((0., float(len(y_labels))))
770774
ax.set_xticklabels(x_labels, rotation=90)
771775
ax.set_yticklabels(y_labels)
772776

0 commit comments

Comments
 (0)