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

Skip to content

Commit 6cbd599

Browse files
committed
hexbin_demo: reduce crowding, use new colormap
1 parent c37c498 commit 6cbd599

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

examples/pylab_examples/hexbin_demo.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717
ymin = y.min()
1818
ymax = y.max()
1919

20-
plt.subplots_adjust(hspace=0.5)
21-
plt.subplot(121)
22-
plt.hexbin(x, y, cmap=plt.cm.YlOrRd_r)
23-
plt.axis([xmin, xmax, ymin, ymax])
24-
plt.title("Hexagon binning")
25-
cb = plt.colorbar()
20+
fig, axs = plt.subplots(ncols=2, sharey=True, figsize=(7, 4))
21+
fig.subplots_adjust(hspace=0.5, left=0.07, right=0.93)
22+
ax = axs[0]
23+
hb = ax.hexbin(x, y, gridsize=50, cmap='inferno')
24+
ax.axis([xmin, xmax, ymin, ymax])
25+
ax.set_title("Hexagon binning")
26+
cb = fig.colorbar(hb, ax=ax)
2627
cb.set_label('counts')
2728

28-
plt.subplot(122)
29-
plt.hexbin(x, y, bins='log', cmap=plt.cm.YlOrRd_r)
30-
plt.axis([xmin, xmax, ymin, ymax])
31-
plt.title("With a log color scale")
32-
cb = plt.colorbar()
29+
ax = axs[1]
30+
hb = ax.hexbin(x, y, gridsize=50, bins='log', cmap='inferno')
31+
ax.axis([xmin, xmax, ymin, ymax])
32+
ax.set_title("With a log color scale")
33+
cb = fig.colorbar(hb, ax=ax)
3334
cb.set_label('log10(N)')
3435

3536
plt.show()

0 commit comments

Comments
 (0)