UnitDblFormatter.py 681 B

12345678910111213141516171819202122232425262728
  1. """UnitDblFormatter module containing class UnitDblFormatter."""
  2. import matplotlib.ticker as ticker
  3. __all__ = ['UnitDblFormatter']
  4. class UnitDblFormatter(ticker.ScalarFormatter):
  5. """
  6. The formatter for UnitDbl data types.
  7. This allows for formatting with the unit string.
  8. """
  9. def __call__(self, x, pos=None):
  10. # docstring inherited
  11. if len(self.locs) == 0:
  12. return ''
  13. else:
  14. return '{:.12}'.format(x)
  15. def format_data_short(self, value):
  16. # docstring inherited
  17. return '{:.12}'.format(value)
  18. def format_data(self, value):
  19. # docstring inherited
  20. return '{:.12}'.format(value)