Skip to content

Add PathCollection test for ps backend #23254

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
merged 1 commit into from
Sep 12, 2022
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: 2 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
The font properties.
angle : float
The rotation angle in degrees anti-clockwise.
ismath : bool or "TeX"
If True, use mathtext parser. If "TeX", use *usetex* mode.
mtext : `matplotlib.text.Text`
The original text object to be rendered.

Expand Down
306 changes: 306 additions & 0 deletions lib/matplotlib/tests/baseline_images/test_backend_ps/scatter.eps

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
import re
import tempfile

import numpy as np
import pytest

from matplotlib import cbook, patheffects, font_manager as fm
from matplotlib import cbook, path, patheffects, font_manager as fm
from matplotlib._api import MatplotlibDeprecationWarning
from matplotlib.figure import Figure
from matplotlib.patches import Ellipse
from matplotlib.testing._markers import needs_ghostscript, needs_usetex
from matplotlib.testing.decorators import check_figures_equal, image_comparison
import matplotlib as mpl
import matplotlib.collections as mcollections
import matplotlib.pyplot as plt


Expand Down Expand Up @@ -298,3 +300,21 @@ def test_multi_font_type42():

fig = plt.figure()
fig.text(0.15, 0.475, "There are 几个汉字 in between!")


@image_comparison(["scatter.eps"])
def test_path_collection():
rng = np.random.default_rng(19680801)
xvals = rng.uniform(0, 1, 10)
yvals = rng.uniform(0, 1, 10)
sizes = rng.uniform(30, 100, 10)
fig, ax = plt.subplots()
ax.scatter(xvals, yvals, sizes, edgecolor=[0.9, 0.2, 0.1], marker='<')
ax.set_axis_off()
paths = [path.Path.unit_regular_polygon(i) for i in range(3, 7)]
offsets = rng.uniform(0, 200, 20).reshape(10, 2)
sizes = [0.02, 0.04]
pc = mcollections.PathCollection(paths, sizes, zorder=-1,
facecolors='yellow', offsets=offsets)
ax.add_collection(pc)
ax.set_xlim(0, 1)