File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,11 @@ def draw(self, renderer):
118
118
mtext .Text .draw (self , renderer )
119
119
self .stale = False
120
120
121
+ def get_tightbbox (self , renderer ):
122
+ # Overwriting the 2d Text behavior which is not valid for 3d.
123
+ # For now, just return None to exclude from layout calculation.
124
+ return None
125
+
121
126
122
127
def text_2d_to_3d (obj , z = 0 , zdir = 'z' ):
123
128
"""Convert a Text to a Text3D object."""
Original file line number Diff line number Diff line change 2
2
3
3
from mpl_toolkits .mplot3d import Axes3D , axes3d , proj3d , art3d
4
4
from matplotlib import cm
5
- from matplotlib .testing .decorators import image_comparison
5
+ from matplotlib .testing .decorators import image_comparison , check_figures_equal
6
6
from matplotlib .collections import LineCollection
7
7
from matplotlib .patches import Circle
8
8
import matplotlib .pyplot as plt
@@ -155,6 +155,19 @@ def f(t):
155
155
ax .set_zlim3d (- 1 , 1 )
156
156
157
157
158
+ @check_figures_equal (extensions = ['png' ])
159
+ def test_tight_layout_text (fig_test , fig_ref ):
160
+ # text is currently ignored in tight layout. So the order of text() and
161
+ # tight_layout() calls should not influence the result.
162
+ ax1 = fig_test .gca (projection = '3d' )
163
+ ax1 .text (.5 , .5 , .5 , s = 'some string' )
164
+ fig_test .tight_layout ()
165
+
166
+ ax2 = fig_ref .gca (projection = '3d' )
167
+ fig_ref .tight_layout ()
168
+ ax2 .text (.5 , .5 , .5 , s = 'some string' )
169
+
170
+
158
171
@image_comparison (baseline_images = ['scatter3d' ], remove_text = True )
159
172
def test_scatter3d ():
160
173
fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments