Find axes limits

plot_utils._find_axes_lim(data_limit, tick_base_unit, direction='upper')[source]

Return a “whole” number to be used as the upper or lower limit of axes.

For example, if the maximum x value of the data is 921.5, and you would like the upper x_limit to be a multiple of 50, then this function returns 950.

Parameters:
  • data_limit (float, int, list<float>, list<int>, tuple<float>, tuple<int>) –

    The upper and/or lower limit(s) of data.
    1. If a tuple (or list) of two elements is provided, then the upper and lower axis limits are automatically determined. (The order of the two elements does not matter.)

    2. If a float or an int is provided, then the axis limit is determined based on the direction provided.

  • tick_base_unit (float) – For example, if you want your axis limit(s) to be a multiple of 20 (such as 80, 120, 2020, etc.), then use 20.

  • direction ({'upper', 'lower'}) – The direction of the limit to be found. For example, if the maximum of the data is 127, and tick_base_unit is 50, then a direction of lower yields a result of 100. This parameter is effective only when data_limit is a scalar.

Returns:

axes_lim – If data_limit is a list/tuple of length 2, return a list: [min_limit, max_limit] (always ordered no matter what the order of data_limit is). If data_limit is a scalar, return the axis limit according to direction.

Return type:

list<float> or float