Description
Still on my offset-text rewrite spree...
Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the public methods available are
Formatter.__call__(self, val, idx)
: computes the label textsFormatter.format_data(self, val)
: not publicly usedFormatter.format_data_short(self, val)
: computes the cursor position textFormatter.get_offset(self)
: returns the offset textFormatter.set_locs(self, locs)
: required for computing the labelsFormatter.fix_minus(self, s)
: overriden only by ScalarFormatter to use a unicode minus
FixedFormatter also provides set_offset_string
.
The commonly used ScalarFormatter and LogFormatter also provide pprint_val
(with different signatures, and not publicly used).
ScalarFormatter also provides a couple of getter/setters (for useOffset
, useLocale
, scientific
, powerlimits
); LogFormatter provides base
and label_minor
as setters for instance variables.
LogFormatterExponent and LogFormatterMathtext are variants of LogFormatter.
EngFormatter also provides format_eng
(not publicly used).
There are also a bunch of instance attributes which are public but probably intended as private.
I propose simplifying the API to the following:
Formatter.get_label_text(self, val: float, idx: int)
: computes the label textsFormatter.get_cursor_text(self, val: float)
: computes the cursor position textFormatter.get_offset_text(self)
andFormatter.set_offset_text(self, s: str)
: get/set the offset textFormatter.set_locs(self, locs: array-like)
: because we need itFormatter.set_uselocale(self, b: bool)
: because there's no reason only ScalarFormatter has it
(the new method names can be made to fallback on the old method names with a deprecation warning in the base class)
and drop or make private basically everything else:
fix_minus
(let's first check if any backend doesn't support unicode)pprint_val/format_eng
- the various instance attributes which should have been private to start with (keeping:
scientific
,powerlimits
,base
,label_minor
, using getter/setters)
and fold the LogFormatterExponent
and LogFormatterMathText
classes into options for the LogFormatter
class.
Thoughts?