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.
| 323 | |
| 324 | |
| 325 | class 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 | |
| 359 | class FuncFormatter(Formatter): |
no outgoing calls
searching dependent graphs…