pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
81 stars 30 forks source link

Spherical plotting of EBSD master pattern #518

Closed hakonanes closed 2 years ago

hakonanes commented 2 years ago

Description of the change

This adds spherical plotting of EBSD master patterns using PyVista. This is the first of many PRs to kikuchipy that uses PyVista, which is a great tool for 3D plotting!

This introduces a new dependency on PyVista. The tests also depend on the panel package for interactive plotting, which I hope should work as in the PyVista documentation.

Progress of the PR

Minimal example of the bug fix or new feature

>>> import kikuchipy as kp
>>> mp = kp.data.nickel_ebsd_master_pattern(projection="stereographic")
>>> mp.plot_spherical(style="points")

mp

See the docs for an interactive version of this plot (without axes and colorbar)!

For reviewers

hakonanes commented 2 years ago

Two issues with the tests:

  1. Lack of display option makes the newly added test fail on Ubuntu and Windows. PyVista seems to fix this by wrapping the pytest call with xfvb-run on Ubuntu, and using their custom action on Windows.
  2. pyvista from PyPI cannot be installed with Python 3.10 due to vtk not being available from PyPI for Python 3.10, see this issue and this discussion for details. According to the issue, vtk will hopefully become available on PyPI for 3.10 this month.
hakonanes commented 2 years ago

I'll leave this PR until vtk is available for Python 3.10 from PyPI.

hakonanes commented 2 years ago

I'm temporarily closing this so that checks are only run in my fork.

hakonanes commented 2 years ago

According to this VTK Discourse thread, vtk v9.2.0 with Python 3.10 support will be released in the next few days... I think waiting for that instead of making 3D plotting optional is the way to go.

hakonanes commented 2 years ago

Making pyvista an optional dependency via an extra named "viz", as in pip install kikuchipy[viz], should work. Users on Python 3.10 who wants this feature can then install vtk via conda-forge and then kikuchipy[viz], or install pyvista as described here.