SigFigFormatter¶
- class SigFigFormatter(sigfig=None, zerotrim=None, base=None)[source]¶
Bases:
matplotlib.ticker.FormatterFormat numbers by retaining the specified number of significant digits.
- Parameters
sigfig (
float, optional) – The number of significant digits. Default is3.zerotrim (
bool, optional) – Whether to trim trailing decimal zeros. Default isrc['formatter.zerotrim']=True.base (
float, optional) – The base unit for rounding. Default is1. For exampleSigFigFormatter(2, base=5)rounds to the nearest 5 with up to 2 significant digits (e.g., 87 –> 85, 8.7 –> 8.5).
Methods Summary
__call__(x[, pos])Convert number to a string.