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

Bugfix subplots legend plot spectra #2099

Conversation

AEljarrat
Copy link
Contributor

Dear all,

I like to use "hs.plot.plot_spectra" to do quick comparisons, especially since the animated legend allows me to set the visibility of the lines. It is also possible to use this command to fill several subplots in the same figure. However, in this case the animated legend cannot by used.

Description of the change

  • This small PR fixes this bug.

Progress of the PR

  • Change implemented.
  • ready for review.

Minimal example of the bug fix or the new feature

>>> %matplotlib qt
>>> import matplotlib.pyplot as plt
>>> import hyperspy.api as hs
>>> import numpy as np
>>> 
>>> Ns = 5
>>> Nc = 256
>>> 
>>> data = np.random.rand(Ns, Nc)
>>> name = np.arange(Ns).astype('str')
>>> s    = hs.signals.Signal1D(data)
>>> 
>>> # This works
>>> hs.plot.plot_spectra(s.inav[:2], legend=name[:2])
>>> hs.plot.plot_spectra(s.inav[2:], legend=name[2:])
>>> 
>>> # This does not work
>>> f, ax = plt.subplots(1, 2)
>>> hs.plot.plot_spectra(s.inav[:2], legend=name[:2], fig=f, ax=ax[0])
>>> hs.plot.plot_spectra(s.inav[2:], legend=name[2:], fig=f, ax=ax[1])

Note that this example can be useful to update the user guide.

@ericpre ericpre changed the base branch from RELEASE_next_minor to RELEASE_next_patch December 1, 2018 14:59
@ericpre ericpre changed the base branch from RELEASE_next_patch to RELEASE_next_minor December 1, 2018 15:00
@ericpre ericpre merged commit c314c82 into hyperspy:RELEASE_next_minor Dec 1, 2018
@ericpre
Copy link
Member

ericpre commented Dec 1, 2018

Nice thanks!

@AEljarrat AEljarrat deleted the bugfix_subplots_legend_plot_spectra branch December 6, 2018 07:58
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.

None yet

2 participants