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

Class FixedFormatter

lib/matplotlib/ticker.py:325–356  ·  view source on GitHub ↗

Return fixed strings for tick labels based only on position, not value. .. note:: `.FixedFormatter` should only be used together with `.FixedLocator`. Otherwise, the labels may end up in unexpected positions.

Source from the content-addressed store, hash-verified

323
324
325class FixedFormatter(Formatter):
326 """
327 Return fixed strings for tick labels based only on position, not value.
328
329 .. note::
330 `.FixedFormatter` should only be used together with `.FixedLocator`.
331 Otherwise, the labels may end up in unexpected positions.
332 """
333
334 def __init__(self, seq):
335 """Set the sequence *seq* of strings that will be used for labels."""
336 self.seq = seq
337 self.offset_string = ''
338
339 def __call__(self, x, pos=None):
340 """
341 Return the label that matches the position, regardless of the value.
342
343 For positions ``pos < len(seq)``, return ``seq[i]`` regardless of
344 *x*. Otherwise return empty string. ``seq`` is the sequence of
345 strings that this object was initialized with.
346 """
347 if pos is None or pos >= len(self.seq):
348 return ''
349 else:
350 return self.seq[pos]
351
352 def get_offset(self):
353 return self.offset_string
354
355 def set_offset_string(self, ofs):
356 self.offset_string = ofs
357
358
359class FuncFormatter(Formatter):

Callers 1

test_autofmt_xdateFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_autofmt_xdateFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…