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

Add CrystalMap.plot(), use matplotlib-scalebar, add xmap notebook #185

Merged
merged 4 commits into from
May 7, 2021

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented May 5, 2021

Signed-off-by: Håkon Wiik Ånes hwaanes@gmail.com

Description of the change

This PR aims to make plotting a CrystalMap simpler.

  • Add CrystalMap.plot() method (using orix.projections.CrystalMapPlot, similar to Vector3d.plot() and Miller.plot())
  • Move CrystalMap notebook from orix-demos and improve it
  • Use matplotlib-scalebar instead of directily using Matplotlib's AnchoredSizeBar. This enables us to remove lots of code, and brings easier customization of the scalebar.
  • Add attributes scalebar and colorbar to CrystalMapPlot for easy access, which are None until add_scalebar() and add_colorbar(), respectively, are called.

Progress of the PR

Minimal example of the bug fix or new feature

This code

>>> xmap
Phase   Orientations                 Name  Space group  Point group  Proper point group       Color
    1   6043 (51.6%)      ferrite/ferrite         None          432                 432    tab:blue
    2   5657 (48.4%)  austenite/austenite         None          432                 432  tab:orange
Properties: iq, dp
Scan unit: um
>>> fig = xmap.plot(overlay="dp", remove_padding=True, return_figure=True)
>>> fig.savefig("/home/hakon/phase_map_dp.png", bbox_inches="tight", pad_inches=0)

produces this phase plot with dot product values in overlay

phase_map_dp_map

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.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes added enhancement New feature or request documentation Relates to the documentation labels May 5, 2021
@hakonanes hakonanes added this to the v0.6.0 milestone May 5, 2021
@hakonanes hakonanes marked this pull request as draft May 5, 2021 17:23
@hakonanes
Copy link
Member Author

hakonanes commented May 6, 2021

Note that most of the added lines (about 1,600) are from the notebook.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes marked this pull request as ready for review May 6, 2021 11:24
@hakonanes
Copy link
Member Author

hakonanes commented May 6, 2021

This is ready for review (the notebook can be viewed here: https://orix--185.org.readthedocs.build/en/185/crystal_map.html). There is no rush, but I would like for it to be part of v0.6.

@pc494 pc494 self-assigned this May 6, 2021
@pc494
Copy link
Member

pc494 commented May 6, 2021

This looks good at a glance, I'll add it to the chunk of stuff I do when I get back to #175, will easily make it into v0.6

@hakonanes
Copy link
Member Author

The notebook has changed very little from the one in orix-demos (nbviewer link), apart from way simpler plotting. The most valuable feedback for me (although all feedback is appreciated!) would be on the CrystalMap.plot() method API, i.e. is it sufficiently customizable and behaves as expected.

Copy link
Member

@pc494 pc494 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking forward to putting this code through it's paces

@pc494 pc494 merged commit 2b790b6 into pyxem:master May 7, 2021
@hakonanes hakonanes deleted the crystal-map-plot-method branch May 7, 2021 13:34
@hakonanes
Copy link
Member Author

Awesome, thanks a lot! Looking forward to using it myself, as it makes life much easier...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to the documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants