hibou.utils.get_ticks#

hibou.utils.get_ticks(data_labels: array, nb_ticks: int, data_index: array = None)#

Returns the indexes and the labels based on the given number of ticks.

Parameters#

data_labelsnp.array

The array that contains the labels.

nb_ticksint

The number of ticks you want to display.

data_indexnp.array, optionnal

By default: None. The indexes of the labels.

Returns#

tuple

The tuple that contains the indexes and the labels.

Examples#

In a case where we need 10 ticks on an axes:

from hibou.utils import get_ticks

ticks_indexes, ticks_labels = get_ticks(x_data_labels, 10)

You can also directly pass the result of get_ticks into the pyplot function:

plt.xticks(*get_ticks(x_data_labels, 10))