Skip to content

Commit 688290f

Browse files
committed
Fix issue with locale comma when not using math text
1 parent 9b16729 commit 688290f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,11 @@ def _impl_locale_comma():
16541654
fmt = ',$\\mathdefault{,%1.1f},$'
16551655
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
16561656
assert x == ',$\\mathdefault{,0{,}5},$'
1657+
# Make sure no brackets are added if not using math text
1658+
ticks = mticker.ScalarFormatter(useMathText=False, useLocale=True)
1659+
fmt = '%1.1f'
1660+
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
1661+
assert x == '0,5'
16571662

16581663

16591664
def test_locale_comma():

lib/matplotlib/ticker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,10 @@ def _format_maybe_minus_and_locale(self, fmt, arg):
516516
Format *arg* with *fmt*, applying Unicode minus and locale if desired.
517517
"""
518518
return self.fix_minus(
519-
# Escape commas introduced by format_string but not those present
520-
# from the beginning in fmt.
519+
# Escape commas introduced by format_string if using math text, but not
520+
# those present from the beginning in fmt.
521521
",".join(locale.format_string(part, (arg,), True)
522-
.replace(",", "{,}")
522+
.replace(",", "{,}" if self._useMathText else ",")
523523
for part in fmt.split(","))
524524
if self._useLocale
525525
else fmt % arg)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy