Repository navigation
Commit 92f9a3b
authored
Add xlabel and ylabel to plot_wfdb (#670)
Fixes #276.
`plot_wfdb` now takes `xlabel` and `ylabel`, lists with a label for each
channel, and passes them to `plot_items`, which already supported them.
Without them the labels are as before: the signal names and units on the
y axes, and `time/second` (or the chosen unit) on the bottom x axis. The
new arguments come last, so calls that pass arguments by position are
unaffected.
```python
wfdb.plot_wfdb(record, xlabel=["", "Time (s)"], ylabel=["Lead II (mV)", "Lead V5 (mV)"])
```
This also fixes `xlabel` in `plot_items`, which has never worked: it
checked the number of labels against `signal.shape[1]` after `signal`
had become a list of channels, so it raised `AttributeError: 'list'
object has no attribute 'shape'`. It now checks against the number of
subplots, as `ylabel` does.
## Testing
- New tests for the default labels, custom labels in `plot_wfdb`, and
`xlabel` in `plot_items`. The last two fail on `main`.
- `pytest -m "not network"`: all pass. Ruff and the docs build pass.
<sub>@tompollard 🟥 red 🦥 sloth · aspen</sub>3 files changed
Lines changed: 50 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
846 | 846 | | |
847 | 847 | | |
848 | 848 | | |
| 849 | + | |
| 850 | + | |
849 | 851 | | |
850 | 852 | | |
851 | 853 | | |
| |||
905 | 907 | | |
906 | 908 | | |
907 | 909 | | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
908 | 916 | | |
909 | 917 | | |
910 | 918 | | |
| |||
927 | 935 | | |
928 | 936 | | |
929 | 937 | | |
930 | | - | |
| 938 | + | |
931 | 939 | | |
932 | 940 | | |
933 | 941 | | |
| |||
968 | 976 | | |
969 | 977 | | |
970 | 978 | | |
971 | | - | |
| 979 | + | |
| 980 | + | |
972 | 981 | | |
973 | 982 | | |
974 | 983 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
178 | 210 | | |
179 | 211 | | |
180 | 212 | | |
| |||
0 commit comments