MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_scatter_logscale

Function test_scatter_logscale

lib/matplotlib/tests/test_backend_pdf.py:677–705  ·  view source on GitHub ↗

Test scatter optimization with logarithmic scales. Ensures bounds checking works correctly in log-transformed coordinates.

(fig_test, fig_ref)

Source from the content-addressed store, hash-verified

675
676@check_figures_equal(extensions=["pdf"])
677def test_scatter_logscale(fig_test, fig_ref):
678 """
679 Test scatter optimization with logarithmic scales.
680
681 Ensures bounds checking works correctly in log-transformed coordinates.
682 """
683 rng = np.random.default_rng(19680801)
684
685 # Create points across several orders of magnitude
686 n_points = 50
687 x = 10 ** (rng.random(n_points) * 4) # 1 to 10000
688 y = 10 ** (rng.random(n_points) * 4)
689 c = rng.random(n_points)
690
691 # Test figure: log scale with points mostly outside view
692 ax_test = fig_test.subplots()
693 ax_test.scatter(x, y, c=c, s=50)
694 ax_test.set_xscale('log')
695 ax_test.set_yscale('log')
696 ax_test.set_xlim(100, 1000) # Only show middle range
697 ax_test.set_ylim(100, 1000)
698
699 # Reference figure: should render identically
700 ax_ref = fig_ref.subplots()
701 ax_ref.scatter(x, y, c=c, s=50)
702 ax_ref.set_xscale('log')
703 ax_ref.set_yscale('log')
704 ax_ref.set_xlim(100, 1000)
705 ax_ref.set_ylim(100, 1000)
706
707
708@check_figures_equal(extensions=["pdf"])

Callers

nothing calls this directly

Calls 6

set_xscaleMethod · 0.80
subplotsMethod · 0.45
scatterMethod · 0.45
set_yscaleMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…