Skip to content

get_datalim returns non-finite values for finite Line3DCollection #18197

Open

Description

@dstansby

Bug report

Bug summary
Discovered whilst investigating #17130, the get_datalim method of Line3DCollection is returning inf values for a finite 3D line collection.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Line3DCollection


segments = [[(0, 0), (1, 1)]]
collection = LineCollection(segments)
fig, ax = plt.subplots()
ax.add_collection(collection)
print('2D:', collection.get_datalim(ax.transAxes))

segments = [[(0, 0, 0), (1, 1, 1)]]
collection = Line3DCollection(segments)

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.add_collection3d(collection)

print('3D:', collection.get_datalim(ax.transAxes))

Actual outcome

2D: Bbox(x0=0.0, y0=0.0, x1=1.0, y1=1.0000000000000002)
3D: Bbox(x0=inf, y0=inf, x1=-inf, y1=-inf)

Expected outcome
The 3D case to have finite and [0, 1] bounds for x and y. Possibly it should also return the z bounds too.

Activity

  1. dstansby commented on Aug 7, 2020

    @dstansby
    MemberAuthor

    The issue is Line3DCollection does

    self._segments3d = segments
    super().set_segments([])

    which sets the segments to an empty list. Because there is no overrridden get_datalim method in Line3DCollection, LineCollection.get_datalim sees only the empty list of segments and returns the inf Bbox. I suspect a solution to this problem will require implementing get_paths() and get_datalim() on Line3DCollection.

  2. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Aug 7, 2020
  3. chrhansm commented on Dec 2, 2020

    @chrhansm

    @dstansby Hi! I'm looking to make my first contribution in an open source project and would like to work on this. I was wondering if this issue is still open?

  4. dopplershift commented on Dec 4, 2020

    @dopplershift
    Contributor

    The issue is still open and I don't see any linked Pull Requests, so have at. The way to be sure it's still a problem is to run the code above and see if it still produces the bad output.

  5. github-actions commented on Aug 16, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  6. oscargus commented on Aug 16, 2023

    @oscargus
    Member

    This is still an issue. May be solved by #25751

  7. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueskeepItems to be ignored by the “Stale” Github Actiontopic: mplot3d

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions