|
11 | 11 | import matplotlib.transforms as mtransforms
|
12 | 12 | from matplotlib.collections import (Collection, LineCollection,
|
13 | 13 | EventCollection, PolyCollection)
|
14 |
| -from matplotlib.testing.decorators import image_comparison |
| 14 | +from matplotlib.testing.decorators import check_figures_equal, image_comparison |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def generate_EventCollection_plot():
|
@@ -301,6 +301,32 @@ def test_add_collection():
|
301 | 301 | assert ax.dataLim.bounds == bounds
|
302 | 302 |
|
303 | 303 |
|
| 304 | +@pytest.mark.style('mpl20') |
| 305 | +@check_figures_equal(extensions=['png']) |
| 306 | +def test_collection_log_datalim(fig_test, fig_ref): |
| 307 | + # Data limits should respect the minimum x/y when using log scale. |
| 308 | + x_vals = [4.38462e-6, 5.54929e-6, 7.02332e-6, 8.88889e-6, 1.12500e-5, |
| 309 | + 1.42383e-5, 1.80203e-5, 2.28070e-5, 2.88651e-5, 3.65324e-5, |
| 310 | + 4.62363e-5, 5.85178e-5, 7.40616e-5, 9.37342e-5, 1.18632e-4] |
| 311 | + y_vals = [0.0, 0.1, 0.182, 0.332, 0.604, 1.1, 2.0, 3.64, 6.64, 12.1, 22.0, |
| 312 | + 39.6, 71.3] |
| 313 | + |
| 314 | + x, y = np.meshgrid(x_vals, y_vals) |
| 315 | + x = x.flatten() |
| 316 | + y = y.flatten() |
| 317 | + |
| 318 | + ax_test = fig_test.subplots() |
| 319 | + ax_test.set_xscale('log') |
| 320 | + ax_test.set_yscale('log') |
| 321 | + ax_test.margins = 0 |
| 322 | + ax_test.scatter(x, y) |
| 323 | + |
| 324 | + ax_ref = fig_ref.subplots() |
| 325 | + ax_ref.set_xscale('log') |
| 326 | + ax_ref.set_yscale('log') |
| 327 | + ax_ref.plot(x, y, marker="o", ls="") |
| 328 | + |
| 329 | + |
304 | 330 | def test_quiver_limits():
|
305 | 331 | ax = plt.axes()
|
306 | 332 | x, y = np.arange(8), np.arange(10)
|
|
0 commit comments