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

Skip to content

Commit 42b798c

Browse files
authored
Merge pull request #22675 from anntzer/cp
Tweak colorbar_placement example.
2 parents a2ddfc0 + 504b0f3 commit 42b798c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

examples/subplots_axes_and_figures/colorbar_placement.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
pcm = ax.pcolormesh(np.random.random((20, 20)) * (col + 1),
2424
cmap=cmaps[col])
2525
fig.colorbar(pcm, ax=ax)
26-
plt.show()
2726

2827
######################################################################
2928
# The first column has the same type of data in both rows, so it may
@@ -38,7 +37,6 @@
3837
pcm = ax.pcolormesh(np.random.random((20, 20)) * (col + 1),
3938
cmap=cmaps[col])
4039
fig.colorbar(pcm, ax=axs[:, col], shrink=0.6)
41-
plt.show()
4240

4341
######################################################################
4442
# Relatively complicated colorbar layouts are possible using this
@@ -53,7 +51,6 @@
5351
fig.colorbar(pcm, ax=[axs[0, 2]], location='bottom')
5452
fig.colorbar(pcm, ax=axs[1:, :], location='right', shrink=0.6)
5553
fig.colorbar(pcm, ax=[axs[2, 1]], location='left')
56-
plt.show()
5754

5855
######################################################################
5956
# Colorbars with fixed-aspect-ratio axes
@@ -75,7 +72,6 @@
7572
ax.set_aspect(1/2)
7673
if row == 1:
7774
fig.colorbar(pcm, ax=ax, shrink=0.6)
78-
plt.show()
7975

8076
######################################################################
8177
# One way around this issue is to use an `.Axes.inset_axes` to locate the
@@ -94,6 +90,7 @@
9490
else:
9591
ax.set_aspect(1/2)
9692
if row == 1:
97-
cax = ax.inset_axes([1.04, 0.2, 0.05, 0.6], transform=ax.transAxes)
93+
cax = ax.inset_axes([1.04, 0.2, 0.05, 0.6])
9894
fig.colorbar(pcm, ax=ax, cax=cax)
95+
9996
plt.show()

0 commit comments

Comments
 (0)