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

Skip to content

Commit f9c1c63

Browse files
committed
FIX: title as well
1 parent 337d1c4 commit f9c1c63

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/matplotlib/tests/test_colorbar.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ def test_colorbar_set_formatter_locator():
982982

983983

984984
def test_offset_text_loc():
985+
plt.style.use('mpl20')
985986
fig, ax = plt.subplots()
986987
np.random.seed(seed=19680808)
987988
pc = ax.pcolormesh(np.random.randn(10, 10)*1e6)
@@ -991,3 +992,17 @@ def test_offset_text_loc():
991992
# colorbar axes. In this case the colorbar axes is the same
992993
# height as the parent, so use the parents bbox.
993994
assert cb.ax.yaxis.offsetText.get_position()[1] > ax.bbox.y1
995+
996+
997+
def test_title_text_loc():
998+
plt.style.use('mpl20')
999+
fig, ax = plt.subplots()
1000+
np.random.seed(seed=19680808)
1001+
pc = ax.pcolormesh(np.random.randn(10, 10))
1002+
cb = fig.colorbar(pc, location='right', extend='max')
1003+
cb.ax.set_title('Aardvark')
1004+
fig.draw_without_rendering()
1005+
# check that the title is in the proper place above the
1006+
# colorbar axes, including its extend triangles....
1007+
assert (cb.ax.title.get_window_extent(fig.canvas.get_renderer()).ymax >
1008+
cb.ax.spines['outline'].get_window_extent().ymax)

0 commit comments

Comments
 (0)