Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Optimize 3D data limits calculation by simplifying direct updates to dataLim #28998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,8 +1391,63 @@

mouseover = property(get_mouseover, set_mouseover) # backcompat.

def set_datalim_x(self, data):

Check failure on line 1394 in lib/matplotlib/artist.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 E302 expected 2 blank lines, found 1 Raw Output: ./lib/matplotlib/artist.py:1394:1: E302 expected 2 blank lines, found 1
"""
Set the x-axis data limits for this 3D plot.

Parameters
----------
data : array-like
The array containing data points for the x-axis.
"""
self._datalim_x = (min(data), max(data))

Check warning on line 1403 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1403

Added line #L1403 was not covered by tests

ax = self.axes

Check warning on line 1405 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1405

Added line #L1405 was not covered by tests
if ax:
ax.dataLim.update_from_data_x(self._datalim_x)

Check warning on line 1407 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1407

Added line #L1407 was not covered by tests

datalim_x = property(lambda self: self._datalim_x, set_datalim_x)


def set_datalim_y(self, data):
"""
Set the y-axis data limits for this 3D plot.

Parameters
----------
data : array-like
The array containing data points for the y-axis.
"""
self._datalim_y = (min(data), max(data))

Check warning on line 1421 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1421

Added line #L1421 was not covered by tests

ax = self.axes

Check warning on line 1423 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1423

Added line #L1423 was not covered by tests
if ax:
ax.dataLim.update_from_data_y(self._datalim_y)

Check warning on line 1425 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1425

Added line #L1425 was not covered by tests

datalim_y = property(lambda self: self._datalim_y, set_datalim_y)


def set_datalim_z(self, data):
"""
Set the z-axis data limits for this 3D plot.

Parameters
----------
data : array-like
The array containing data points for the z-axis.
"""
self._datalim_z = (min(data), max(data))

Check warning on line 1439 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1439

Added line #L1439 was not covered by tests

ax = self.axes

Check warning on line 1441 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1441

Added line #L1441 was not covered by tests
if ax:
ax.dataLim.update_from_data_z(self._datalim_z)

Check warning on line 1443 in lib/matplotlib/artist.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/artist.py#L1443

Added line #L1443 was not covered by tests

datalim_z = property(lambda self: self._datalim_z, set_datalim_z)




def _get_tightbbox_for_layout_only(obj, *args, **kwargs):

Check failure on line 1450 in lib/matplotlib/artist.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 E303 too many blank lines (4) Raw Output: ./lib/matplotlib/artist.py:1450:1: E303 too many blank lines (4)
"""
Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
*for_layout_only* kwarg; this helper tries to use the kwarg but skips it
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2341,6 +2341,11 @@

def _unpack_to_numpy(x):
"""Internal helper to extract data from e.g. pandas and xarray objects."""
if isinstance(x, ak.Array):

Check failure on line 2344 in lib/matplotlib/cbook.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 F821 undefined name 'ak' Raw Output: ./lib/matplotlib/cbook.py:2344:22: F821 undefined name 'ak'
# Normalize akward irregular arrays to numpy array
xtmp = ak.to_numpy(ak.flatten(x))

Check failure on line 2346 in lib/matplotlib/cbook.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 F821 undefined name 'ak' Raw Output: ./lib/matplotlib/cbook.py:2346:16: F821 undefined name 'ak'

Check failure on line 2346 in lib/matplotlib/cbook.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 F821 undefined name 'ak' Raw Output: ./lib/matplotlib/cbook.py:2346:28: F821 undefined name 'ak'
print("Entrou")
return xtmp

Check warning on line 2348 in lib/matplotlib/cbook.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/cbook.py#L2346-L2348

Added lines #L2346 - L2348 were not covered by tests
if isinstance(x, np.ndarray):
# If numpy, return directly
return x
Expand Down
Loading