Skip to content

Conversation

argerlt
Copy link
Collaborator

@argerlt argerlt commented Oct 3, 2025

Description of the change

This adds the HomochoricPlot class, as well as an example showing all 4 of the orientation projections available in ORIX.

This is ready for review, except I found a small error when creating this example that I haven't been able to fix. Namely, in the included example, if the line under the #TODO comment is uncommented and ran, it fails to plot in the proper subplot. this is because of how the logic in Orientation.scatter.

If anyone wants to try to fix this, go for it, otherwise I will do it in the next day or two.

Progress of the PR

Minimal example of the bug fix or new feature

Copied from part of the included example:

import matplotlib.pyplot as plt
import numpy as np

from orix.plot import IPFColorKeyTSL, register_projections
from orix.quaternion import Orientation, OrientationRegion
from orix.quaternion.symmetry import D3

plt.close("all")
register_projections()  # Register our custom Matplotlib projections
np.random.seed(2319)  # Create reproducible random data

n = 30
ori = Orientation.random(n, symmetry=D3)
# create orientation-dependent colormap for more informative plots.
color_key = IPFColorKeyTSL(D3)
clrs = color_key.orientation2color(ori)

############################################################################
# Orientation plots can be made in one of two ways. The first and simplest
# is via Orientation.scatter().
fig = plt.figure(figsize=(12, 3), layout="constrained")
ori.scatter(c=clrs, position=(1, 4, 1), projection="axangle", figure=fig)
fig.axes[0].set_title("Axis-Angle Projection")
ori.scatter(c=clrs, position=(1, 4, 2), projection="rodrigues", figure=fig)
fig.axes[1].set_title("Rodrigues Projection")
ori.scatter(c=clrs, position=(1, 4, 3), projection="homochoric", figure=fig)
fig.axes[2].set_title("Homochoric Projection")
# TODO: Following line does not plot properly due to the logic in
# Orientation.scatter
# ori.scatter(c=clrs, position=(1, 4, 4), projection="ipf", figure=fig)
plt.tight_layout()

# This can also be used to create standalone figures
ori.scatter(c=clrs, projection="ipf")
plt.tight_layout()


For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@argerlt argerlt added this to the v0.14.0 milestone Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant