Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
2 changes: 1 addition & 1 deletion lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def get_label_width(self, lev, fmt, fsize):
fig = self.axes.figure
width = (text.Text(0, 0, lev, figure=fig,
size=fsize, fontproperties=self.labelFontProps)
.get_window_extent(fig.canvas.get_renderer()).width)
.get_window_extent(mpl.tight_layout.get_renderer(fig)).width)
width *= 72 / fig.dpi
return width

Expand Down
6 changes: 6 additions & 0 deletions lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,9 @@ def test_contour_linewidth(
X = np.arange(4*3).reshape(4, 3)
cs = ax.contour(X, linewidths=call_linewidths)
assert cs.tlinewidths[0][0] == expected


@pytest.mark.backend("pdf")
def test_label_nonagg():
# This should not crash even if the canvas doesn't have a get_renderer().
plt.clabel(plt.contour([[1, 2], [3, 4]]))