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

Savefig #2

Open
josepaulo1233 opened this issue Sep 15, 2023 · 2 comments
Open

Savefig #2

josepaulo1233 opened this issue Sep 15, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@josepaulo1233
Copy link

When I use ramanspy.plot.peaks it's returns an axes.

ax = ramanspy.plot.peaks(preprocessed_spectrum, prominence=0.08)

ax.savefig('test.png')

AttributeError Traceback (most recent call last)
c:\Users\Maria Clara\OneDrive\Área de Trabalho\MAC\Raman\5A.ipynb Célula 12 line 1
----> 1 ax.savefig('test.png')

AttributeError: 'Axes' object has no attribute 'savefig'

How to transform ax in a figure?

@dgeorgiev21
Copy link
Collaborator

dgeorgiev21 commented Sep 16, 2023

Thank you for reaching out!

The plotting functionality of RamanSPy is built upon matplotlib.

In matplotlib, you can save Figure objects, but not standalone Axes objects.

One way to work around that is as described here:

ax = ramanspy.plot.peaks(preprocessed_spectrum, prominence=0.08)
ax.get_figure().savefig('test.png')


If you find RamanSPy useful, please consider starring the project on GitHub! Your support means a lot!

@dgeorgiev21
Copy link
Collaborator

I have left this issue open since the method ramanspy.plot.peaks (as well as ramanspy.plot.spectra and ramanspy.plot.mean_spectra) should ideally take an Axes object(s) as an optional argument(s) to allow better control over the plotting of figures and subfigures. Then, creating and saving a figure would look like:

fig, axs = plt.subplots(...)
ramanspy.plot.peaks(preprocessed_spectrum, prominence=0.08, ..., ax=axs[...])
fig.savefig(...)

Any contributions are more than welcome!


If you find RamanSPy useful, please consider starring the project on GitHub! Your support means a lot!

@dgeorgiev21 dgeorgiev21 added the enhancement New feature or request label Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants