FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

TST: Use text placeholders for empty legends by QuLogic · Pull Request #29908 · matplotlib/matplotlib · GitHub

Repository navigation

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

Filter by extension

Filter by extension .pdf  (2) .png  (4) .py  (5) .svg  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
6 changes: 2 additions & 4 deletions lib/matplotlib/tests/test_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4593,14 +4593,12 @@ def test_hist_stacked_weighted():


@image_comparison(['stem.png'], style='mpl20', remove_text=True)
def test_stem():
def test_stem(text_placeholders):
x = np.linspace(0.1, 2 * np.pi, 100)

fig, ax = plt.subplots()
# Label is a single space to force a legend to be drawn, but to avoid any
# text being drawn
ax.stem(x, np.cos(x),
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label='stem')
ax.legend()


Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_backend_pdf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,16 @@ def test_pdfpages_fspath():
pdf.savefig(plt.figure())


@image_comparison(['hatching_legend.pdf'])
def test_hatching_legend():
@image_comparison(['hatching_legend.pdf'], style='mpl20')
def test_hatching_legend(text_placeholders):
"""Test for correct hatching on patches in legend"""
fig = plt.figure(figsize=(1, 2))

a = Rectangle([0, 0], 0, 0, facecolor="green", hatch="XXXX")
b = Rectangle([0, 0], 0, 0, facecolor="blue", hatch="XXXX")

# Verify that hatches in PDFs work after empty labels. See
# https://github.com/matplotlib/matplotlib/issues/4469
fig.legend([a, b, a, b], ["", "", "", ""])


Expand Down
15 changes: 8 additions & 7 deletions lib/matplotlib/tests/test_bbox_tight.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
from mpl_toolkits.axes_grid1.inset_locator import inset_axes


@image_comparison(['bbox_inches_tight'], remove_text=True,
@image_comparison(['bbox_inches_tight'], remove_text=True, style='mpl20',
savefig_kwarg={'bbox_inches': 'tight'})
def test_bbox_inches_tight():
def test_bbox_inches_tight(text_placeholders):
#: Test that a figure saved using bbox_inches='tight' is clipped correctly
data = [[66386, 174296, 75131, 577908, 32015],
[58230, 381139, 78045, 99308, 160454],
[89135, 80552, 152558, 497981, 603535],
[78415, 81858, 150656, 193263, 69638],
[139361, 331509, 343164, 781380, 52269]]

col_labels = row_labels = [''] * 5
col_labels = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
row_labels = [f'{x} year' for x in (100, 50, 20, 10, 5)]

rows = len(data)
ind = np.arange(len(col_labels)) + 0.3 # the x locations for the groups
Expand All @@ -31,13 +32,13 @@ def test_bbox_inches_tight():
# the bottom values for stacked bar chart
fig, ax = plt.subplots(1, 1)
for row in range(rows):
ax.bar(ind, data[row], width, bottom=yoff, align='edge', color='b')
ax.bar(ind, data[row], width, bottom=yoff, align='edge')
yoff = yoff + data[row]
cell_text.append([''])
cell_text.append([f'{x / 1000:1.1f}' for x in yoff])
plt.xticks([])
plt.xlim(0, 5)
plt.legend([''] * 5, loc=(1.2, 0.2))
fig.legend([''] * 5, bbox_to_anchor=(0, 0.2), loc='lower left')
plt.legend(['1', '2', '3', '4', '5'], loc=(1.2, 0.2))
fig.legend(['a', 'b', 'c', 'd', 'e'], bbox_to_anchor=(0, 0.2), loc='lower left')
# Add a table at the bottom of the axes
cell_text.reverse()
plt.table(cellText=cell_text, rowLabels=row_labels, colLabels=col_labels,
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/tests/test_lines.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ def test_marker_as_markerstyle():


@image_comparison(['striped_line.png'], remove_text=True, style='mpl20')
def test_striped_lines():
def test_striped_lines(text_placeholders):
rng = np.random.default_rng(19680801)
_, ax = plt.subplots()
ax.plot(rng.uniform(size=12), color='orange', gapcolor='blue',
linestyle='--', lw=5, label=' ')
linestyle='--', lw=5, label='blue in orange')
ax.plot(rng.uniform(size=12), color='red', gapcolor='black',
linestyle=(0, (2, 5, 4, 2)), lw=5, label=' ', alpha=0.5)
linestyle=(0, (2, 5, 4, 2)), lw=5, label='black in red', alpha=0.5)
ax.legend(handlelength=5)


Expand Down
9 changes: 4 additions & 5 deletions lib/matplotlib/tests/test_patheffects.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ def test_collection():
'edgecolor': 'blue'})


@image_comparison(['tickedstroke'], remove_text=True, extensions=['png'],
tol=0.22) # Increased tolerance due to fixed clipping.
def test_tickedstroke():
@image_comparison(['tickedstroke.png'], remove_text=True, style='mpl20')
def test_tickedstroke(text_placeholders):
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 4))
path = Path.unit_circle()
patch = patches.PathPatch(path, facecolor='none', lw=2, path_effects=[
Expand All @@ -149,13 +148,13 @@ def test_tickedstroke():
ax1.set_xlim(-2, 2)
ax1.set_ylim(-2, 2)

ax2.plot([0, 1], [0, 1], label=' ',
ax2.plot([0, 1], [0, 1], label='C0',
path_effects=[path_effects.withTickedStroke(spacing=7,
angle=135)])
nx = 101
x = np.linspace(0.0, 1.0, nx)
y = 0.3 * np.sin(x * 8) + 0.4
ax2.plot(x, y, label=' ', path_effects=[path_effects.withTickedStroke()])
ax2.plot(x, y, label='C1', path_effects=[path_effects.withTickedStroke()])

ax2.legend()

Expand Down

Back | FazBrowse Home | New Git URL