8000 Add a test for scatter autolim on log scale. · matplotlib/matplotlib@279ec45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 279ec45

Browse files
committed
Add a test for scatter autolim on log scale.
This test is a distilled out of #16552.
1 parent 7e69d18 commit 279ec45

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import matplotlib.transforms as mtransforms
1212
from matplotlib.collections import (Collection, LineCollection,
1313
EventCollection, PolyCollection)
14-
from matplotlib.testing.decorators import image_comparison
14+
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1515

1616

1717
def generate_EventCollection_plot():
@@ -301,6 +301,32 @@ def test_add_collection():
301301
assert ax.dataLim.bounds == bounds
302302

303303

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+
304330
def test_quiver_limits():
305331
ax = plt.axes()
306332
x, y = np.arange(8), np.arange(10)

0 commit comments

Comments
 (0)
0