File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
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 @@ -336,10 +336,11 @@ class FormatStrFormatter(Formatter):
336
336
The format string should have a single variable format (%) in it.
337
337
It will be applied to the value (not the position) of the tick.
338
338
339
- Negative numeric values will use a dash, not a Unicode minus; use mathtext
340
- to get a Unicode minus by wrapping the format specifier with $ (e.g.
341
- "$%g$").
339
+ Negative numeric values (e.g., -1) will use a dash, not a Unicode minus;
340
+ use mathtext to get a Unicode minus by wrapping the format specifier with $
341
+ (e.g. "$%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 (e.g., -1) will use a dash, not a Unicode minus;
364
+ use mathtext to get a Unicode minus by wrapping the format specifier with $
365
+ (e.g. "${x}$").
366
+
367
+ It is typically unnecessary to explicitly construct `.StrMethodFormatter`
368
+ objects, as `~.Axis.set_major_formatter` directly accepts the format string
369
+ 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