Skip to content

Impossible to get the z value of a line in 3D #26146

@nippotam

Description

@nippotam

Bug summary

Traceback (most recent call last):
File "slider.py", line 318, in
plot_functions_3D(functions_list, colors_list)
File "slider.py", line 181, in plot_functions_3D
add_arrow_3d(line3d, d=10)
File "slider.py", line 88, in add_arrow_3d
zdata = line.get_zdata()
AttributeError: 'Line3D' object has no attribute 'get_zdata'

Code for reproduction

ax_main = fig.add_subplot(111, projection='3d')  # Use 3D projection
   for function in list_functions:
        result = [function(ti) for ti in t]
        x, y, z = zip(*result)
        line, = ax_main.plot(x, y, z)  # Use plot() for 3D plot
        add_arrow_3d(line, d=10)
        lines.append(line)

def add_arrow_3d(line):
    """
    Add an arrow to a line in a 3D plot every d steps.
    xdata = line.get_xdata()
    ydata = line.get_ydata()
    zdata = line.get_zdata() # -> error


seems not coherent here in art3D.py 
 @artist.allow_rasterization
    def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)
        self.set_data(xs, ys) #-> zs is not used
        super().draw(renderer)
        self.stale = False

and here : 
    def set_3d_properties(self, zs=0, zdir='z'):
        xs = self.get_xdata()
        ys = self.get_ydata()
        zs = np.broadcast_to(zs, len(XS)) #-> why we have not self.get_zdata() ?
        self._verts3d = juggle_axes(xs, ys, zs, zdir)
        self.stale = True

Actual outcome

Traceback (most recent call last):
File "slider.py", line 318, in
plot_functions_3D(functions_list, colors_list)
File "slider.py", line 181, in plot_functions_3D
add_arrow_3d(line3d, d=10)
File "slider.py", line 88, in add_arrow_3d
zdata = line.get_zdata()
AttributeError: 'Line3D' object has no attribute 'get_zdata'

Expected outcome

the z value

Additional information

No response

Operating system

Mac OS

Matplotlib Version

Version: ImageMagick 7.1.1-6 Q16-HDRI x86_64 21020 https://imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC HDRI Modules OpenMP(5.0) Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib Compiler: gcc (4.2) Usage: import [options ...] [ file ]

Matplotlib Backend

No response

Python version

3.7

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy