File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ def draw(self, renderer):
113113 mtext .Text .draw (self , renderer )
114114 self .stale = False
115115
116+ def get_tightbbox (self , renderer ):
117+ # Overwriting the 2d Text behavior which is not valid for 3d.
118+ # For now, just return None to exclude from layout calculation.
119+ return None
120+
116121
117122def text_2d_to_3d (obj , z = 0 , zdir = 'z' ):
118123 """Convert a Text to a Text3D object."""
Original file line number Diff line number Diff line change 22
33from mpl_toolkits .mplot3d import Axes3D , axes3d , proj3d , art3d
44from matplotlib import cm
5- from matplotlib .testing .decorators import image_comparison
5+ from matplotlib .testing .decorators import image_comparison , check_figures_equal
66from matplotlib .collections import LineCollection
77from matplotlib .patches import Circle
88import matplotlib .pyplot as plt
@@ -163,6 +163,19 @@ def f(t):
163163 ax .set_zlim3d (- 1 , 1 )
164164
165165
166+ @check_figures_equal (extensions = ['png' ])
167+ def test_tight_layout_text (fig_test , fig_ref ):
168+ # text is currently ignored in tight layout. So the order of text() and
169+ # tight_layout() calls should not influence the result.
170+ ax1 = fig_test .gca (projection = '3d' )
171+ ax1 .text (.5 , .5 , .5 , s = 'some string' )
172+ fig_test .tight_layout ()
173+
174+ ax2 = fig_ref .gca (projection = '3d' )
175+ fig_ref .tight_layout ()
176+ ax2 .text (.5 , .5 , .5 , s = 'some string' )
177+
178+
166179@image_comparison (baseline_images = ['scatter3d' ], remove_text = True )
167180def test_scatter3d ():
168181 fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments