You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: cm fontset in log scale does not use Unicode minus #21540
Yes, works fine for me on v3.4.3 and the following code:
frommatplotlib.pyplotimport*plot([-10, 10], [-10, 10])
yscale('symlog', linthresh=.1)
show()
``I'm going to close as not an issue as two of us have checked - @Atcold feel free to comment/re-open if you think we'vemissedsomething.
Ah, bmh sets the cm fontset, and that doesn't appear to support the minus sign properly. Also, it doesn't seem like the Log formatters do any minus sign glyph substitution, but I may have missed it.
You can replicate this more easily by setting mpl.rcParams['mathtext.fontset'] = 'cm', and if you don't mind going back to DejaVu Sans, can work around it by setting mpl.rcParams['mathtext.fontset'] = 'dejavusans' after setting the style.
changed the title [-][Bug]: minuses are shown as dashes when choosing the log scale[/-][+][Bug]: cm fontset in log scale does not use Unicode minus[/+]on Nov 20, 2021
diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py
index 6d8fa5419b..c759403bbf 100644
--- a/lib/matplotlib/ticker.py+++ b/lib/matplotlib/ticker.py@@ -1066,7 +1066,7 @@ class LogFormatterMathtext(LogFormatter):
if x == 0: # Symlog
return r'$\mathdefault{0}$'
- sign_string = '-' if x < 0 else ''+ sign_string = self.fix_minus('-') if x < 0 else ''
x = abs(x)
b = self._base
though I'm not sure if this should be applied to LogFormatter as well (probably it should).
Activity
QuLogic commentedon Nov 4, 2021
This looks fine to me:

Maybe it's your theme?
dstansby commentedon Nov 6, 2021
Yes, works fine for me on v3.4.3 and the following code:
Atcold commentedon Nov 19, 2021
Adding
style.use(['bmh'])will show the bug.So the theme is breaking it.
Not sure how to reopen this issue.
@QuLogic that didn't really look too fine to me, haha.

QuLogic commentedon Nov 20, 2021
Ah,
bmhsets thecmfontset, and that doesn't appear to support the minus sign properly. Also, it doesn't seem like the Log formatters do any minus sign glyph substitution, but I may have missed it.You can replicate this more easily by setting
mpl.rcParams['mathtext.fontset'] = 'cm', and if you don't mind going back to DejaVu Sans, can work around it by settingmpl.rcParams['mathtext.fontset'] = 'dejavusans'after setting the style.[-][Bug]: minuses are shown as dashes when choosing the log scale[/-][+][Bug]: cm fontset in log scale does not use Unicode minus[/+]QuLogic commentedon Nov 20, 2021
A possible fix may be to do:
though I'm not sure if this should be applied to
LogFormatteras well (probably it should).anntzer commentedon Nov 20, 2021
Agreed that we should use fix_minus in as many places as possible. (But see also #21687.)
Atcold commentedon Dec 3, 2021
Thanks for going to the bottom of this.
Ensure log formatters use Unicode minus
subfigure _axstack property