[Python] Matplotlib cannot be shown

Discussão em 'Python' iniciado por Stack, Junho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I want to visualize pandas.DataFrame using matplotlib on linux. My code is:

    import pandas as pd
    import matplotlib.pyplot as plt

    sep = "\n\n\n"

    df = pd.read_csv("dataset.csv")
    print("df:")
    print(df, end=sep)

    print("Info:")
    print(df.info(), end=sep)

    print("Description:")
    print(df.describe(), end=sep)

    df.plot(subplots=True, figsize=(25, 15))
    df.hist(bins=20, figsize=(25, 15))
    plt.show()


    But it says:

    UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
    plt.show()


    I tried to add tkinter backend with:

    import matplotlib
    matplotlib.use("TkAgg")


    But it cannot find agg, although I have tkinter, and gives:

    ModuleNotFoundError: No module named 'tkinter'


    So, are there any options to show plot without installing additional libraries?

    python 3.10, matplotlib 3.8.1

    Continue reading...

Compartilhe esta Página