[Python] MatPlotlib: Patches not being displayed

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have just started experimenting with matplotlib, since I often come across instances where I need to plot some data, for which matplotlib seems an excellent tool. I attempted to adapt the ellipse example in the main site, so as to draw two circles instead, how ever after running the code, I find that none of the patches are displayed, I am not able to figure out what exactly is wrong... here is the code. Thanks in Advance.

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib
    import matplotlib.patches as mpatches

    plt.axis([-3,3,-3,3])
    ax = plt.axes([-3,3,-3,3])
    # add a circle
    art = mpatches.Circle([0,0], radius = 1, color = 'r', axes = ax)

    ax.add_artist(art)

    #add another circle
    art = mpatches.Circle([0,0], radius = 0.1, color = 'b', axes = ax)

    ax.add_artist(art)

    print ax.patches

    plt.show()

    Continue reading...

Compartilhe esta Página