ppinard/matplotlib-scalebar

Change \mu to \textmu

SirJohnFranklin opened this issue · 3 comments

Hey,

nice package!
One thing came to my mind using it: The \mu for micrometer is of italic type which is not correct in my opinion.

You could change:
latexrepr = '$\\mu$m'
to
latexrepr = '$\\mathrm{\\mu}$m'

in dimensions.py, line 88.

Best,
SJF

Committed, it will be part of the next release.

Just for future reference: If there is need for a custom symbol or text, this can be accomplished with the label_formatter attribute. I originally implemented it to get the proper $\textmu$ in the font type I wanted.

As example: Before the implemented change one could do the following:

def custom_formatter(value, unit):
    if unit=='$\\mu$m':
        unit = '$\\mathrm{\\mu}$m'
    return '{} {}'.format(value, unit)

my_bar = ScaleBar(..., label_formatter=custom_formatter)

Good to know. It is good to see that the label_formatter can be used for many things 😄