class SigFigFormatter(sigfig=None, zerotrim=None, base=None)[source]

Bases: matplotlib.ticker.Formatter

Format numbers by retaining the specified number of significant digits.

  • sigfig (float, optional) – The number of significant digits. Default is 3.

  • zerotrim (bool, optional) – Whether to trim trailing decimal zeros. Default is rc['formatter.zerotrim'] = True.

  • base (float, optional) – The base unit for rounding. Default is 1. For example SigFigFormatter(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.