@@ -13,7 +13,8 @@ def plot_items(signal=None, ann_samp=None, ann_sym=None, fs=None,
13
13
time_units = 'samples' , sig_name = None , sig_units = None ,
14
14
xlabel = None , ylabel = None , title = None , sig_style = ['' ],
15
15
ann_style = ['r*' ], ecg_grids = [], figsize = None ,
16
- return_fig = False , return_fig_axes = False ):
16
+ sharex = False , sharey = False , return_fig = False ,
17
+ return_fig_axes = False ):
17
18
"""
18
19
Subplot individual channels of signals and/or annotations.
19
20
@@ -78,6 +79,10 @@ def plot_items(signal=None, ann_samp=None, ann_sym=None, fs=None,
78
79
also be set to 'all' for all channels. Major grids at 0.5mV, and minor
79
80
grids at 0.125mV. All channels to be plotted with grids must have
80
81
`sig_units` equal to 'uV', 'mV', or 'V'.
82
+ sharex, sharey : bool, optional
83
+ Controls sharing of properties among x (`sharex`) or y (`sharey`) axes.
84
+ If True: x- or y-axis will be shared among all subplots.
85
+ If False, each subplot x- or y-axis will be independent.
81
86
figsize : tuple, optional
82
87
Tuple pair specifying the width, and height of the figure. It is the
83
88
'figsize' argument passed into matplotlib.pyplot's `figure` function.
@@ -108,7 +113,7 @@ def plot_items(signal=None, ann_samp=None, ann_sym=None, fs=None,
108
113
sig_len , n_sig , n_annot , n_subplots = get_plot_dims (signal , ann_samp )
109
114
110
115
# Create figure
111
- fig , axes = create_figure (n_subplots , figsize )
116
+ fig , axes = create_figure (n_subplots , sharex , sharey , figsize )
112
117
113
118
if signal is not None :
114
119
plot_signal (signal , sig_len , n_sig , fs , time_units , sig_style , axes )
@@ -200,7 +205,7 @@ def get_plot_dims(signal, ann_samp):
200
205
return sig_len , n_sig , n_annot , max (n_sig , n_annot )
201
206
202
207
203
- def create_figure (n_subplots , figsize ):
208
+ def create_figure (n_subplots , sharex , sharey , figsize ):
204
209
"""
205
210
Create the plot figure and subplot axes.
206
211
@@ -210,21 +215,21 @@ def create_figure(n_subplots, figsize):
210
215
The number of subplots to generate.
211
216
figsize : tuple
212
217
The figure's width, height in inches.
218
+ sharex, sharey : bool, optional
219
+ Controls sharing of properties among x (`sharex`) or y (`sharey`) axes.
220
+ If True: x- or y-axis will be shared among all subplots.
221
+ If False, each subplot x- or y-axis will be independent.
213
222
214
223
Returns
215
224
-------
216
225
fig : matplotlib plot object
217
226
The entire figure that will hold each subplot.
218
227
axes : list
219
228
The information needed for each subplot.
220
-
221
229
"""
222
- fig = plt .figure (figsize = figsize )
223
- axes = []
224
-
225
- for i in range (n_subplots ):
226
- axes .append (fig .add_subplot (n_subplots , 1 , i + 1 ))
227
-
230
+ fig , axes = plt .subplots (
231
+ nrows = n_subplots , ncols = 1 , sharex = sharex , sharey = sharey , figsize = figsize
232
+ )
228
233
return fig , axes
229
234
230
235
0 commit comments