@@ -732,3 +732,30 @@ def test_scatter_polar(fig_test, fig_ref):
732732 ax_ref = fig_ref .subplots (subplot_kw = {'projection' : 'polar' })
733733 ax_ref .scatter (theta , r , c = c , s = 50 )
734734 ax_ref .set_ylim (0 , 2 )
735+
736+
737+ @check_figures_equal (extensions = ["pdf" ])
738+ def test_hexbin_negative_offsets (fig_test , fig_ref ):
739+ """
740+ Test path collection culling with non-canvas-space offsets.
741+
742+ Hexbin uses a repeated polygon path with offsets transformed by
743+ AffineDeltaTransform. The transformed offsets are displacements, not the
744+ final canvas-space marker centers, so PDF backend culling must account for
745+ the transformed path bounds as well.
746+ """
747+ rng = np .random .default_rng (19680801 )
748+ x = rng .normal (size = 10_000 )
749+ y = rng .normal (size = 10_000 )
750+
751+ ax_test = fig_test .subplots ()
752+ ax_test .hexbin (x , y , gridsize = 25 , edgecolors = "none" )
753+ ax_test .set_xlim (- 2.0 , 2.0 )
754+ ax_test .set_ylim (- 2.0 , 2.0 )
755+ ax_test .set_axis_off ()
756+
757+ ax_ref = fig_ref .subplots ()
758+ ax_ref .hexbin (x + 2.0 , y + 2.0 , gridsize = 25 , edgecolors = "none" )
759+ ax_ref .set_xlim (0.0 , 4.0 )
760+ ax_ref .set_ylim (0.0 , 4.0 )
761+ ax_ref .set_axis_off ()
0 commit comments