-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
[Fix] ppg_plot() was not returning matplotlib.Figure #678
Conversation
…r LFHF feature for HRV
Thanks for opening this pull request! We'll make sure it's perfect before merging 🤗 |
Codecov Report
@@ Coverage Diff @@
## dev #678 +/- ##
==========================================
- Coverage 52.42% 52.38% -0.04%
==========================================
Files 276 276
Lines 12424 12430 +6
==========================================
- Hits 6513 6512 -1
- Misses 5911 5918 +7
Continue to review full report at Codecov.
|
Thanks for that PR, unfortunately, we recently changed that behaviour on behaviour to not return the figure, as it was causing some issues, among which double figures showing up in the console and inconsistent return type which is not a good programming practice (that said, it's possible that documentation has to be adjusted in some places!) In principle thanks to the arcanes of matplotlib you can still recover the figure and save it to disk as follows: import matplotlib.pyplot as plt
import neurokit2 as nk
# Generate 15 seconds of PPG signal (recorded at 250 samples / second)
ppg = nk.ppg_simulate(duration=15, sampling_rate=250, heart_rate=70, random_state=333)
# Process it
signals, info = nk.ppg_process(ppg, sampling_rate=250)
# Visualize the processing
nk.ppg_plot(signals, sampling_rate=250)
# Save it
plt.tight_layout()
plt.savefig("ppg.png", dpi=300) Or even fig = plt.gcf()
fig.set_size_inches(10, 6, forward=True)
fig.savefig("ppg2.png", dpi=300) Let us know if it works, and if it does, you can edit your PR to just leave the documentation fix :) |
Thanks for your feedback 😁. Your example code to save the plots worked very well! |
Apparently there is an error building the new docs induced by my change in |
I fixed the issues, merging now :) thanks! |
Hi...
Description
I needed to store the results of
ppg_plot()
in a file on disk (easier to inspect than doing it manually in the notebook). However, the function did not return the objectmatplotlib.figure
so I could usefig.savefig([path])
, even though the documentation says that it returns a figure.If the PR is accepted, I can check similar behavior for the other variables.
Proposed Changes
matplotlib.figure.Figure
forppg_plot()
instead of just plotting the image on the notebook.hrv_frequency()
, it was missing.Checklist
Here are some things to check before creating the PR. If you encounter any issues, do let us know :)