@@ -979,3 +979,30 @@ def test_colorbar_set_formatter_locator():
979979 fmt = LogFormatter ()
980980 cb .minorformatter = fmt
981981 assert cb .ax .yaxis .get_minor_formatter () is fmt
982+
983+
984+ def test_offset_text_loc ():
985+ plt .style .use ('mpl20' )
986+ fig , ax = plt .subplots ()
987+ np .random .seed (seed = 19680808 )
988+ pc = ax .pcolormesh (np .random .randn (10 , 10 )* 1e6 )
989+ cb = fig .colorbar (pc , location = 'right' , extend = 'max' )
990+ fig .draw_without_rendering ()
991+ # check that the offsetText is in the proper place above the
992+ # colorbar axes. In this case the colorbar axes is the same
993+ # height as the parent, so use the parents bbox.
994+ 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