-
Notifications
You must be signed in to change notification settings - Fork 302
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
Align signals horizontally in plot_wfdb (if possible) #390
Conversation
Whoops, fixed a typo. |
wfdb/plot/plot.py
Outdated
@@ -121,7 +121,7 @@ def plot_items( | |||
signal=None, | |||
ann_samp=None, | |||
ann_sym=None, | |||
fs=None, | |||
frame_freq=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo 6 in demo.ipynb
uses the old name.
wfdb/plot/plot.py
Outdated
@@ -217,11 +216,11 @@ def plot_items( | |||
sampling_freq : number or sequence, optional | |||
The sampling frequency or frequencies of the signals. If this is a | |||
list, it must have the same length as the number of channels. If | |||
unspecified, defaults to `fs`. | |||
unspecified, defaults to `frame_freq`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these two parameters is rather confusing. Can you explain why both sampling_freq
and frame_freq
are both needed?
ACK, seems messier than I thought.
What if we forget about the frame_freq thing, forget about
sharex=True+units="samples", and instead just:
- use seconds by default in plot_wfdb
- use sharex=True in plot_wfdb *except* when units are set to samples
|
Yea, let's fix the
|
This argument allows the caller to specify whether the horizontal axes should be synchronized across all channels (subplots) in a plot. In general, this behavior is desirable as it lets the viewer see the temporal relationship between channels. However, in the case where the record is multi-frequency *and* we are displaying sample numbers on the horizontal axis, matplotlib unfortunately does not appear to have a way to synchronize the axes automatically. Therefore, in the default "auto" case, enable X sharing as long as the time units for all channels are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
In
plot_wfdb
, add an argumentsharex
which controls whether X axes are shared between subplots.(This means that multiple channels will always appear time-aligned with each other, even if one channel starts or ends with a block of NaNs. It also means that if you use the pan/zoom buttons to navigate, the channels will stay aligned with each other.)
sharex=True
is generally desirable behavior; however, if the time units are sample numbers and the record is multi-frequency, then it's not possible (AFAICT) with matplotlib to have the axes synchronized while displaying different units on different subplots. So we disable sharex by default in that case.Finally,
plot_wfdb
will usetime_units="seconds"
by default, which I think is useful because it's consistent (across databases) and familiar.(original pull request description follows)
A few changes to improve plotting of multiple channels and multiple frequencies:Forplot_items
and various internal functions, rename thefs
argument toframe_freq
so it is (perhaps) more clear what it means for multi-frequency data. (I'm still not completely satisfied and thinkplot_items
is harder to use than it needs to be.)Allow specifyingtime_units="frames"
as an alternative to "samples", "seconds", etc.The big change:plot_wfdb
usessharex=True
. This means that multiple channels will always appear time-aligned with each other, even if one channel starts or ends with a block of NaNs. It also means that if you use the pan/zoom buttons to navigate, the channels will stay aligned with each other.plot_wfdb
will usetime_units="seconds"
by default, which I think is useful because it's consistent (across databases) and familiar.(fixes issue #373)