[Python] UserWarning: FixedFormatter should only be used together with FixedLocator

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have used for a long time small subroutines to format axes of charts I'm plotting. A couple of examples:

    def format_y_label_thousands(): # format y-axis tick labels formats
    ax = plt.gca()
    label_format = '{:,.0f}'
    ax.set_yticklabels([label_format.format(x) for x in ax.get_yticks().tolist()])

    def format_y_label_percent(): # format y-axis tick labels formats
    ax = plt.gca()
    label_format = '{:.1%}'
    ax.set_yticklabels([label_format.format(x) for x in ax.get_yticks().tolist()])


    However, after an update to matplotlib yesterday, I get the following warning when calling any of these two functions:

    UserWarning: FixedFormatter should only be used together with FixedLocator
    ax.set_yticklabels([label_format.format(x) for x in ax.get_yticks().tolist()])


    What is the reason for such a warning? I couldn't figure it out looking into matplotlib's documentation.

    Continue reading...

Compartilhe esta Página