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

Skip to content

autoscale_view is not working with Line3DCollection #17130

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
sylee957 opened this issue Apr 14, 2020 · 1 comment · Fixed by #28403
Closed

autoscale_view is not working with Line3DCollection #17130

sylee957 opened this issue Apr 14, 2020 · 1 comment · Fixed by #28403

Comments

@sylee957
Copy link

Bug report

Bug summary

I found multiple issues of autoscale_view for Line3DCollection that

  1. autoscale_view takes no effect for plots with Line3DCollection.
  2. autoscale_view even breaks the original bounds and forces it to be a unit cube if it is used with ax.set_autoscale_on(True).

This is reported from the downstream issue sympy/sympy#19106

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Line3DCollection

z = np.linspace(-4 * np.pi, 4 * np.pi, 100)
x = np.sin(z)
y = np.cos(z)

segments = []
for i in range(len(z)-1):
    z0, x0, y0 = z[i], x[i], y[i]
    z1, x1, y1 = z[i+1], x[i+1], y[i+1]
    segments.append([(x0, y0, z0), (x1, y1, z1)])

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

ax.add_collection3d(collection)
ax.set_xlim3d(-1, 1)
ax.set_ylim3d(-1, 1)
ax.set_zlim3d(-4*np.pi, 4*np.pi)
ax.set_autoscale_on(True)
ax.autoscale_view()
plt.show()

Actual outcome

image

Expected outcome

image

Matplotlib version

  • Operating system:
  • Matplotlib version: 3.2
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.7.7
  • Jupyter version (if applicable):
  • Other libraries:
@github-actions
Copy link

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!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jul 26, 2023
@oscargus oscargus added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Jul 26, 2023
@timhoffm timhoffm removed the keep Items to be ignored by the “Stale” Github Action label Jun 24, 2024
@QuLogic QuLogic added this to the v3.9.1 milestone Jun 24, 2024
@Chrillebon Chrillebon mentioned this issue Aug 8, 2024
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment