Skip to content
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

Pole Density Function #484

Open
maclariz opened this issue Apr 11, 2024 · 3 comments
Open

Pole Density Function #484

maclariz opened this issue Apr 11, 2024 · 3 comments
Labels
documentation-examples Consider making into a documentation example

Comments

@maclariz
Copy link

Just had some fun with pole density function today, but I found an issue with documentation and I have a question.

First the issue:
This page has plotting into an existing figure:
https://orix.readthedocs.io/en/stable/tutorials/pole_density_function.html
But this page doesn't even mention a "figure" argument you can call:
https://orix.readthedocs.io/en/stable/reference/generated/orix.measure.pole_density_function.html

Secondly, the question:
Can I use this function to plot within an existing defined axis within a multiple axis figure (e.g. created with plt.subplots)?

@harripj
Copy link
Collaborator

harripj commented Apr 11, 2024

@maclariz you're right. The measure.pole_density_function function performs the computation and returns the histogram data and edges, and is useful for accessing the data or performing further processing on the histogram data.

There is a similarly named function (perhaps confusingly) StereographicPlot.pole_density_function which is essentially a convenience function around measure.pole_density_function mentioned above, and can be used to quickly produce a plot. You can see this in the code here. (There is also a density plot for the inverse pole figure).

To answer your second point, yes absolutely. There are a couple examples in the tutorial you linked above. You just need to define the subplot projection as stereographic to use the StereographicPlot functions.

Here is an example with an independent plot (note that the orix.plot import is necessary to register the projection within Matplotlib):

import orix.plot
from orix.vector import Vector3d

import numpy as np
import matplotlib.pyplot as plt

v = Vector3d(np.random.randn(1_000, 3))

fig = plt.figure(figsize=(10, 5))
ax1 = fig.add_subplot(121, projection="stereographic")
ax2 = fig.add_subplot(122)

ax1.pole_density_function(v)
x = np.arange(10)
ax2.plot(x, x**2)

image

@hakonanes hakonanes added the documentation-examples Consider making into a documentation example label Apr 11, 2024
@hakonanes
Copy link
Member

This should be added to the examples gallery!

@maclariz
Copy link
Author

Thanks. This is helpful. Will use this. Sorry for late reply, was travelling on a different project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-examples Consider making into a documentation example
Projects
None yet
Development

No branches or pull requests

3 participants