MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / MyFormatter

Class MyFormatter

galleries/examples/ticks/date_index_formatter.py:69–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69class MyFormatter(Formatter):
70 def __init__(self, dates, fmt='%a'):
71 self.dates = dates
72 self.fmt = fmt
73
74 def __call__(self, x, pos=0):
75 """Return the label for time x at position pos."""
76 try:
77 return self.dates[round(x)].item().strftime(self.fmt)
78 except IndexError:
79 pass
80
81
82ax2.xaxis.set_major_formatter(MyFormatter(r["date"], '%a'))

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…