简体   繁体   中英

PyVista: AttributeError: 'Plotter' object has no attribute 'ren_win'

I am using the example code of the documentation from PyVista:

import pyvista as pv
import matplotlib.pyplot as plt
from pyvista import examples

mesh = examples.load_random_hills()

p = pv.Plotter()
p.add_mesh(mesh, color=True)
p.show()

zval = p.get_image_depth()

plt.figure()
plt.imshow(zval)
plt.colorbar(label='Distance to Camera')
plt.title('Depth image')
plt.xlabel('X Pixel')
plt.ylabel('Y Pixel')
plt.show()

Unfortunately I receive the following Error:

File "C:\Users\user\Anaconda3\lib\site-packages\pyvista\plotting\plotting.py", line 3110, in get_image_depth
    ifilter.SetInput(self.ren_win)

AttributeError: 'Plotter' object has no attribute 'ren_win'

I don't know why the error occurs and I couldn't find anything about this problem.

The output of pv.Report is:

  Date: Mon May 03 14:02:50 2021 Mitteleuropäische Sommerzeit



  Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]

           pyvista : 0.29.1
               vtk : 9.0.1
             numpy : 1.16.5
           imageio : 2.6.0
           appdirs : 1.4.4
            scooby : 0.5.7
            meshio : 4.4.1
        matplotlib : 3.3.4
             PyQt5 : 5.9.2
           IPython : 7.8.0
             scipy : 1.3.1
              tqdm : 4.36.1

  Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for
  Intel(R) 64 architecture applications

The answer is that the image has to be stored. So I have to insert p.store_image = True before p.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM