Skip to content

Commit 81cc698

Browse files
committed
update styling stuff - collection, check func
1 parent 37d6cd8 commit 81cc698

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

fooof/plts/settings.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@
4040
# Custom style arguments are those that are custom-handled by the plot style function
4141
CUSTOM_STYLE_ARGS = ['title_fontsize', 'label_size', 'tick_labelsize',
4242
'legend_size', 'legend_loc']
43-
STYLERS = ['axis_styler', 'line_styler', 'custom_styler']
44-
STYLE_ARGS = AXIS_STYLE_ARGS + LINE_STYLE_ARGS + CUSTOM_STYLE_ARGS + STYLERS
43+
44+
# Define list of available style functions - these can also be replaced by arguments
45+
STYLERS = ['axis_styler', 'line_styler', 'collection_styler', 'custom_styler']
46+
47+
# Collect the full set of possible style related input keyword arguments
48+
STYLE_ARGS = \
49+
AXIS_STYLE_ARGS + LINE_STYLE_ARGS + COLLECTION_STYLE_ARGS + CUSTOM_STYLE_ARGS + STYLERS
4550

4651
## Define default values for plot aesthetics
4752
# These are all custom style arguments

fooof/plts/style.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@
66
import matplotlib.pyplot as plt
77

88
from fooof.plts.settings import (AXIS_STYLE_ARGS, LINE_STYLE_ARGS, COLLECTION_STYLE_ARGS,
9-
STYLE_ARGS, LABEL_SIZE, LEGEND_SIZE, LEGEND_LOC,
10-
TICK_LABELSIZE, TITLE_FONTSIZE)
9+
CUSTOM_STYLE_ARGS, STYLE_ARGS, TICK_LABELSIZE, TITLE_FONTSIZE,
10+
LABEL_SIZE, LEGEND_SIZE, LEGEND_LOC)
1111

1212
###################################################################################################
1313
###################################################################################################
1414

15+
def check_style_options():
16+
"""Check the list of valid style arguments that can be passed into plot functions."""
17+
18+
print('Valid style arguments:')
19+
for label, options in zip(['Axis', 'Line', 'Collection', 'Custom'],
20+
[AXIS_STYLE_ARGS, LINE_STYLE_ARGS,
21+
COLLECTION_STYLE_ARGS, CUSTOM_STYLE_ARGS]):
22+
print(' ', label, '\t', ', '.join(options))
23+
24+
1525
def style_spectrum_plot(ax, log_freqs, log_powers, grid=True):
1626
"""Apply style and aesthetics to a power spectrum plot.
1727
@@ -229,9 +239,19 @@ def style_plot(func, *args, **kwargs):
229239
By default, this function applies styling with the `apply_style` function. Custom
230240
functions for applying style can be passed in using `apply_style` as a keyword argument.
231241
232-
The `apply_style` function calls sub-functions for applying style different plot elements,
233-
and these sub-functions can be overridden by passing in alternatives for `axis_styler`,
234-
`line_styler`, and `custom_styler`.
242+
The `apply_style` function calls sub-functions for applying different plot elements, including:
243+
244+
- `axis_styler`: apply style options to an axis
245+
- `line_styler`: applies style options to lines objects in a plot
246+
- `collection_styler`: applies style options to collections objects in a plot
247+
- `custom_style`: applies custom style options
248+
249+
Each of these sub-functions can be overridden by passing in alternatives.
250+
251+
To see the full set of style arguments that are supported, run the following code:
252+
253+
>>> from fooof.plts.style import check_style_options
254+
>>> check_style_options()
235255
"""
236256

237257
@wraps(func)

fooof/tests/plts/test_styles.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
###################################################################################################
77
###################################################################################################
88

9+
def test_check_style_options():
10+
11+
check_style_options()
12+
913
def test_style_spectrum_plot(skip_if_no_mpl):
1014

1115
# Create a dummy plot and style it

0 commit comments

Comments
 (0)