#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Why is my "add_patch" script not working


    # I am trying to plot an image with a tilted rectangle on it.
    # I need a bunch of images with different rectangles. So I use "for" loop.
    # The 1st image is fine.
    # But the 2nd image have both the 1st and the 2nd rectangles on it.
    # Could you help me figure out whats the problem?

    My script is something like:

    for i in range(len(ID)):
    fig = plt.figure(1)
    ax = plt.subplot(1,1,1)

    plt.imshow(dat)
    rect=Rectangle(.......)

    tr=mpl.transforms.Affine2D().rotate_deg(angle[i])+ax.transData
    rect.set_transform(tr)

    ax.add_patch(rect)
    plt.savefig(str(ID[i])+'.eps')
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    You use matplotlib?
    I suggest you look through the samples at
    http://matplotlib.org/gallery.html

    wherein you'll find something similar to what you want and modify the code to fit your need.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Question


    I think the main problem might be in the "for" loop.
    Its a problem that for the 2nd image, I only want to plot a certain rectangle for it. While at the moment, the rectangle for the 1st image is also plotted on the 2nd image.
    The script that makes the rectangle is fine.

    The examples don't have this kind of answers.

    Originally Posted by b49P23TIvg
    You use matplotlib?
    I suggest you look through the
    wherein you'll find something similar to what you want and modify the code to fit your need.

IMN logo majestic logo threadwatch logo seochat tools logo