File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 3
3
Dollar ticks
4
4
============
5
5
6
- Use a `~.ticker.FormatStrFormatter` to prepend dollar signs on y-axis labels.
6
+ Use a format string to prepend dollar signs on y-axis labels.
7
7
8
8
.. redirect-from:: /gallery/pyplots/dollar_ticks
9
9
"""
10
+
10
11
import matplotlib .pyplot as plt
11
12
import numpy as np
12
13
Original file line number Diff line number Diff line change @@ -340,6 +340,7 @@ class FormatStrFormatter(Formatter):
340
340
to get a Unicode minus by wrapping the format specifier with $ (e.g.
341
341
"$%g$").
342
342
"""
343
+
343
344
def __init__ (self , fmt ):
344
345
self .fmt = fmt
345
346
@@ -358,7 +359,16 @@ class StrMethodFormatter(Formatter):
358
359
359
360
The field used for the tick value must be labeled *x* and the field used
360
361
for the tick position must be labeled *pos*.
362
+
363
+ Negative numeric values will use a dash, not a Unicode minus; use mathtext
364
+ to get a Unicode minus by wrapping the format specifier with $ (e.g.
365
+ "${x}$").
366
+
367
+ It is typically unnecessary to explicitly construct `.StrMethodFormatter`
368
+ objects, as `~.Axis.set_major_formatter` also directly accepts the format
369
+ string itself.
361
370
"""
371
+
362
372
def __init__ (self , fmt ):
363
373
self .fmt = fmt
364
374
You can’t perform that action at this time.
0 commit comments