File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 33Dollar ticks
44============
55
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.
77
88.. redirect-from:: /gallery/pyplots/dollar_ticks
99"""
10+
1011import matplotlib .pyplot as plt
1112import numpy as np
1213
Original file line number Diff line number Diff line change @@ -336,10 +336,11 @@ class FormatStrFormatter(Formatter):
336336 The format string should have a single variable format (%) in it.
337337 It will be applied to the value (not the position) of the tick.
338338
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$").
342342 """
343+
343344 def __init__ (self , fmt ):
344345 self .fmt = fmt
345346
@@ -358,7 +359,16 @@ class StrMethodFormatter(Formatter):
358359
359360 The field used for the tick value must be labeled *x* and the field used
360361 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.
361370 """
371+
362372 def __init__ (self , fmt ):
363373 self .fmt = fmt
364374
You can’t perform that action at this time.
0 commit comments