|
4 | 4 | import re |
5 | 5 | import tempfile |
6 | 6 |
|
| 7 | +import numpy as np |
7 | 8 | import pytest |
8 | 9 |
|
9 | | -from matplotlib import cbook, patheffects, font_manager as fm |
| 10 | +from matplotlib import cbook, path, patheffects, font_manager as fm |
10 | 11 | from matplotlib._api import MatplotlibDeprecationWarning |
11 | 12 | from matplotlib.figure import Figure |
12 | 13 | from matplotlib.patches import Ellipse |
13 | 14 | from matplotlib.testing._markers import needs_ghostscript, needs_usetex |
14 | 15 | from matplotlib.testing.decorators import check_figures_equal, image_comparison |
15 | 16 | import matplotlib as mpl |
| 17 | +import matplotlib.collections as mcollections |
16 | 18 | import matplotlib.pyplot as plt |
17 | 19 |
|
18 | 20 |
|
@@ -298,3 +300,21 @@ def test_multi_font_type42(): |
298 | 300 |
|
299 | 301 | fig = plt.figure() |
300 | 302 | fig.text(0.15, 0.475, "There are 几个汉字 in between!") |
| 303 | + |
| 304 | + |
| 305 | +@image_comparison(["scatter.eps"]) |
| 306 | +def test_path_collection(): |
| 307 | + rng = np.random.default_rng(19680801) |
| 308 | + xvals = rng.uniform(0, 1, 10) |
| 309 | + yvals = rng.uniform(0, 1, 10) |
| 310 | + sizes = rng.uniform(30, 100, 10) |
| 311 | + fig, ax = plt.subplots() |
| 312 | + ax.scatter(xvals, yvals, sizes, edgecolor=[0.9, 0.2, 0.1], marker='<') |
| 313 | + ax.set_axis_off() |
| 314 | + paths = [path.Path.unit_regular_polygon(i) for i in range(3, 7)] |
| 315 | + offsets = rng.uniform(0, 200, 20).reshape(10, 2) |
| 316 | + sizes = [0.02, 0.04] |
| 317 | + pc = mcollections.PathCollection(paths, sizes, zorder=-1, |
| 318 | + facecolors='yellow', offsets=offsets) |
| 319 | + ax.add_collection(pc) |
| 320 | + ax.set_xlim(0, 1) |
0 commit comments