Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Backport PR #12693 on branch v3.0.x (Workaround Text3D breaking tight_layout()) #12750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 5 lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def draw(self, renderer):
mtext.Text.draw(self, renderer)
self.stale = False

def get_tightbbox(self, renderer):
# Overwriting the 2d Text behavior which is not valid for 3d.
# For now, just return None to exclude from layout calculation.
return None


def text_2d_to_3d(obj, z=0, zdir='z'):
"""Convert a Text to a Text3D object."""
Expand Down
15 changes: 14 additions & 1 deletion 15 lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from mpl_toolkits.mplot3d import Axes3D, axes3d, proj3d, art3d
from matplotlib import cm
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.decorators import image_comparison, check_figures_equal
from matplotlib.collections import LineCollection
from matplotlib.patches import Circle
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -155,6 +155,19 @@ def f(t):
ax.set_zlim3d(-1, 1)


@check_figures_equal(extensions=['png'])
def test_tight_layout_text(fig_test, fig_ref):
# text is currently ignored in tight layout. So the order of text() and
# tight_layout() calls should not influence the result.
ax1 = fig_test.gca(projection='3d')
ax1.text(.5, .5, .5, s='some string')
fig_test.tight_layout()

ax2 = fig_ref.gca(projection='3d')
fig_ref.tight_layout()
ax2.text(.5, .5, .5, s='some string')


@image_comparison(baseline_images=['scatter3d'], remove_text=True)
def test_scatter3d():
fig = plt.figure()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.