Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions matplotlib_scalebar/scalebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,33 +96,25 @@ def _validate_legend_loc(loc):
return loc


defaultParams.update(
{
"scalebar.length_fraction": [0.2, validate_float],
"scalebar.width_fraction": [0.01, validate_float],
"scalebar.location": ["upper right", _validate_legend_loc],
"scalebar.pad": [0.2, validate_float],
"scalebar.border_pad": [0.1, validate_float],
"scalebar.sep": [5, validate_float],
"scalebar.frameon": [True, validate_bool],
"scalebar.color": ["k", validate_color],
"scalebar.box_color": ["w", validate_color],
"scalebar.box_alpha": [1.0, validate_float],
"scalebar.scale_loc": ["bottom", _validate_scale_loc],
"scalebar.label_loc": ["top", _validate_label_loc],
"scalebar.rotation": ["horizontal", _validate_rotation],
}
)


_all_deprecated = getattr(matplotlib, "_all_deprecated", {})


# Recreate the validate function
matplotlib.rcParams.validate = dict(
(key, converter)
for key, (default, converter) in defaultParams.items()
if key not in _all_deprecated
scalebar_params = {
"scalebar.length_fraction": [0.2, validate_float],
"scalebar.width_fraction": [0.01, validate_float],
"scalebar.location": ["upper right", _validate_legend_loc],
"scalebar.pad": [0.2, validate_float],
"scalebar.border_pad": [0.1, validate_float],
"scalebar.sep": [5, validate_float],
"scalebar.frameon": [True, validate_bool],
"scalebar.color": ["k", validate_color],
"scalebar.box_color": ["w", validate_color],
"scalebar.box_alpha": [1.0, validate_float],
"scalebar.scale_loc": ["bottom", _validate_scale_loc],
"scalebar.label_loc": ["top", _validate_label_loc],
"scalebar.rotation": ["horizontal", _validate_rotation],
}
defaultParams.update(scalebar_params)
# Update the validate function
matplotlib.rcParams.validate.update(
dict((key, converter) for key, (_, converter) in scalebar_params.items())
)

# Dimension lookup
Expand Down