[Python] How to format x,y coords in plotnine

Discussão em 'Python' iniciado por Stack, Agosto 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have very simple plotnine example:

    from plotnine import ggplot, aes, geom_line
    import pandas as pd

    df = pd.DataFrame([[1,1], [2,4], [3,9], [4,16], [5,25]], columns=['x', 'y'])
    print(df)

    g = (
    ggplot(df)
    + aes(x="x", y="y")
    + geom_line()
    )

    g.show()


    Everything is ok, except (x,y) coordinates displayed in bottom right corner (marked red): [​IMG]

    Is there some way to change formatting, so that I can limit number of decimal digits (something like f"{x:.4f}")?

    python 3.10.12
    plotnine 0.14.6

    Continue reading...

Compartilhe esta Página