def unitpicker(a, llim=<NUM_LIT:0.1>, denominator=None, focus_stage=None):
if not isinstance(a, (int, float)):<EOL><INDENT>a = nominal_values(a)<EOL>a = np.percentile(a[~np.isnan(a)], <NUM_LIT>)<EOL><DEDENT>if denominator is not None:<EOL><INDENT>pd = pretty_element(denominator)<EOL><DEDENT>else:<EOL><INDENT>pd = '<STR_LIT>'<EOL><DEDENT>if focus_stage == '<STR_LIT>':<EOL><INDENT>udict = {<NUM_LIT:0>: '<STR_LIT>' + pd,<EOL><NUM_LIT:1>: '<STR_LIT>' + pd,<EOL><NUM_LIT:2>: '<STR_LIT>' + pd,<EOL><NUM_LIT:3>: '<STR_LIT>' + pd,<EOL><NUM_LIT:4>: '<STR_LIT>' + pd,<EOL><NUM_LIT:5>: '<STR_LIT>' + pd}<EOL><DEDENT>elif focus_stage == '<STR_LIT>':<EOL><INDENT>udict = {<NUM_LIT:0>: '<STR_LIT>' + pd,<EOL><NUM_LIT:1>: '<STR_LIT>' + pd,<EOL><NUM_LIT:2>: '<STR_LIT>' + pd,<EOL><NUM_LIT:3>: '<STR_LIT>' + pd,<EOL><NUM_LIT:4>: '<STR_LIT>' + pd,<EOL><NUM_LIT:5>: '<STR_LIT>' + pd}<EOL><DEDENT>elif focus_stage in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>udict = udict = {<NUM_LIT:0>: '<STR_LIT>',<EOL><NUM_LIT:1>: '<STR_LIT>',<EOL><NUM_LIT:2>: '<STR_LIT>',<EOL><NUM_LIT:3>: '<STR_LIT>',<EOL><NUM_LIT:4>: '<STR_LIT>',<EOL><NUM_LIT:5>: '<STR_LIT>'}<EOL><DEDENT>else:<EOL><INDENT>udict = {<NUM_LIT:0>: '<STR_LIT>', <NUM_LIT:1>: '<STR_LIT>', <NUM_LIT:2>: '<STR_LIT>', <NUM_LIT:3>: '<STR_LIT>', <NUM_LIT:4>: '<STR_LIT>', <NUM_LIT:5>: '<STR_LIT>'}<EOL><DEDENT>a = abs(a)<EOL>n = <NUM_LIT:0><EOL>if a < llim:<EOL><INDENT>while a < llim:<EOL><INDENT>a *= <NUM_LIT:1000><EOL>n += <NUM_LIT:1><EOL><DEDENT><DEDENT>return float(<NUM_LIT:1000>**n), udict[n]<EOL>
Determines the most appropriate plotting unit for data.

Parameters
----------
a : float or array-like
    number to optimise. If array like, the 25% quantile is optimised.
llim : float
    minimum allowable value in scaled data.

Returns
-------
(float, str)
    (multiplier, unit)