ppinard/matplotlib-scalebar

Force certain scale bar length

habi opened this issue · 5 comments

habi commented

First; thanks for making this!

I'm plotting several images together in a subplot, as seen in the image below (for science reasons some information is blurred).

issue

For sake of consistency I'd like to have a 1 mm scale bar on all the images.
Is this possible?

habi commented

I suspect the label_formatter is used for this, but I cannot seem to find out how...

No the label_formatter won't do what you are looking for. It only changes the way the text is displayed and not the length of the scale bar. I think what you described would be a very nice addition but I have to think the proper way of implementing it.

I guess the constructor would need two additional arguments: desired_value and desired_unit. In your example, deaired_value=1 and desired_unit='mm'. I am just wondering what would happen if someone selects a combination where the scale bar is either too long for the subplot or too small to be visible.

habi commented
habi commented

Thanks for implementing this (in the relevant branch), it works as intended!
Attached is an overview of several differently sized images (again, blurred for science reasons) which all have the same-length scale bar on them.
scalebars

Works as expected! I ❤️ matplotlib-scalebar! :D