Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions matplotlib_scalebar/scalebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
def _validate_legend_loc(loc):
rc = matplotlib.RcParams()
rc["legend.loc"] = loc
return loc

defaultParams.update(
{
Expand Down
27 changes: 27 additions & 0 deletions matplotlib_scalebar/test_scalebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,33 @@ def scalebar():
plt.draw()


def test_mpl_rcParams_update():
"""
Test if scalebar params are updated accurately in matplotlib rcParams
"""

params = {
"scalebar.length_fraction": 0.2,
"scalebar.height_fraction": 0.01, # deprecated
"scalebar.width_fraction": 0.01,
"scalebar.location": "upper right",
"scalebar.pad": 0.2,
"scalebar.border_pad": 0.1,
"scalebar.sep": 5,
"scalebar.frameon": True,
"scalebar.color": "k",
"scalebar.box_color": "w",
"scalebar.box_alpha": 1.0,
"scalebar.scale_loc": "bottom",
"scalebar.label_loc": "top",
"scalebar.rotation": "horizontal",
}
matplotlib.rcParams.update(params)

for key, value in params.items():
assert matplotlib.rcParams[key] == value


def test_scalebar_dx_m(scalebar):
assert scalebar.get_dx() == pytest.approx(0.5, abs=1e-2)
assert scalebar.dx == pytest.approx(0.5, abs=1e-2)
Expand Down