Skip to content

Commit

Permalink
Fix issue matplotlib#23129: Remove non-affine transformation from dat…
Browse files Browse the repository at this point in the history
…alim computations in Collections
  • Loading branch information
Gerson-M-Ferreira committed Apr 4, 2024
1 parent bf6cc30 commit ec7a79f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,10 @@ def get_datalim(self, transData):
# No paths to transform
return transforms.Bbox.null()

if not transform.is_affine:
paths = [transform.transform_path_non_affine(p) for p in paths]
# Don't convert transform to transform.get_affine() here because
# we may have transform.contains_branch(transData) but not
# transforms.get_affine().contains_branch(transData). But later,
# be careful to only apply the affine part that remains.
# Don't convert transform to transform.get_affine() here because
# we may have transform.contains_branch(transData) but not
# transforms.get_affine().contains_branch(transData). But later,
# be careful to only apply the affine part that remains.

offsets = self.get_offsets()

Expand Down
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ def test_collection_log_datalim(fig_test, fig_ref):
ax_ref.plot(x, y, marker="o", ls="")


@mpl.style.context('mpl20')
@check_figures_equal(extensions=['png'])
def test_collection_log_datalim_order_dependency(fig_test, fig_ref):
xy = np.c_[np.arange(50), np.linspace(1, 100, 50)]
lines_test = mpl.collections.LineCollection(segments=[xy])
lines_ref = mpl.collections.LineCollection(segments=[xy])

ax_test = fig_test.subplots()
ax_test.set_xscale('log')
ax_test.set_yscale('log')
ax_test.add_collection(lines_test)
ax_test.autoscale_view()

ax_ref = fig_ref.subplots()
ax_ref.add_collection(lines_ref)
ax_ref.set_xscale('log')
ax_ref.set_yscale('log')
ax_ref.autoscale_view()


def test_quiver_limits():
ax = plt.axes()
x, y = np.arange(8), np.arange(10)
Expand Down

0 comments on commit ec7a79f

Please sign in to comment.