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

Skip to content

[MNT]: Refactor autoscaling in 3D #28444

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

Open
timhoffm opened this issue Jun 24, 2024 · 2 comments
Open

[MNT]: Refactor autoscaling in 3D #28444

timhoffm opened this issue Jun 24, 2024 · 2 comments

Comments

@timhoffm
Copy link
Member

Summary

From #28403 (review):

Current logic

Extract all data coordinates xyz from the artist and feed them into auto_scale_xyz().

This updates the xy_dataLim, zz_dataLim BBoxes via .Bbox.update_from_data_xy/x/y(), which in turn creates a Path and calls .Bbox.update_from_path().

This is quite a lot data pushing (and maybe copying) just to update dataLim bboxes.

Proposed logic

Separation of concerns: The Artists should have a function to get their data lims. These limits should be used to update the Bbox. Basically some Bbox.update_from_box, a kind of an in-place Bbox.union, which we don't seem to have.

Essentially, we have should implement a 3D variant of Collection.get_datalim` for 3D.

Proposed fix

Rough outline: We may start minimal with rolling a small

class _Bbox3d:
    def __init__(self, points):
        ((self.xmin, self.xmax),
         (self.ymin, self.ymax),
         (self.zmin, self.zmax)) = points

    def to_bbox_xy(self):
        return Bbox(((self.xmin, self.xmax), (self.ymin, self.ymax)))

    def to_bbox_zz(self):
        # first component contains z, second is unused
        return Bbox(((self.zmin, self.zmax), (0, 0)))

and implement _get_datalim3d() -> _Bbox3d on the 3d collections.

Then

def add_collection(col, autolim=True):
    ...
    if autolim:
        self.auto_scale_lim(col.get_datalim3d())

and

def auto_scale_lim(bbox3d):
     ...
     self.dataLim_xy.update_from_box(bbox3d.to_bbox_xy())
     self.dataLim_zz.update_from_box(bbox3d.to_bbox_zz())
@Thierno88
Copy link

Can I suggest a solution on this issue?

@rcomer
Copy link
Member

rcomer commented Oct 20, 2024

Hi @Thierno88, anyone is welcome to work on anything, so if you think you see a way forward, please go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants