@@ -968,3 +968,30 @@ def test_boundaries():
968968 fig , ax = plt .subplots (figsize = (2 , 2 ))
969969 pc = ax .pcolormesh (np .random .randn (10 , 10 ), cmap = 'RdBu_r' )
970970 cb = fig .colorbar (pc , ax = ax , boundaries = np .linspace (- 3 , 3 , 7 ))
971+
972+
973+ def test_offset_text_loc ():
974+ plt .style .use ('mpl20' )
975+ fig , ax = plt .subplots ()
976+ np .random .seed (seed = 19680808 )
977+ pc = ax .pcolormesh (np .random .randn (10 , 10 )* 1e6 )
978+ cb = fig .colorbar (pc , location = 'right' , extend = 'max' )
979+ fig .draw_without_rendering ()
980+ # check that the offsetText is in the proper place above the
981+ # colorbar axes. In this case the colorbar axes is the same
982+ # height as the parent, so use the parents bbox.
983+ assert cb .ax .yaxis .offsetText .get_position ()[1 ] > ax .bbox .y1
984+
985+
986+ def test_title_text_loc ():
987+ plt .style .use ('mpl20' )
988+ fig , ax = plt .subplots ()
989+ np .random .seed (seed = 19680808 )
990+ pc = ax .pcolormesh (np .random .randn (10 , 10 ))
991+ cb = fig .colorbar (pc , location = 'right' , extend = 'max' )
992+ cb .ax .set_title ('Aardvark' )
993+ fig .draw_without_rendering ()
994+ # check that the title is in the proper place above the
995+ # colorbar axes, including its extend triangles....
996+ assert (cb .ax .title .get_window_extent (fig .canvas .get_renderer ()).ymax >
997+ cb .ax .spines ['outline' ].get_window_extent ().ymax )
0 commit comments