1

I use Embedding Python in C++, in my program, I have to run the python module many times. Unfortunately, the plt.show() only gets the figure one time, the others get the null figure

import matplotlib.pyplot as plt  
import numpy as np
from matplotlib.patches import Ellipse, Circle
import time
def show(x,y,x1,y1):
    fig=plt.figure()
    fig.gca().invert_yaxis()
    ax1 = fig.add_subplot(111)
    cir1 = Circle(xy = (x1, y1), radius=0.02, alpha=0.5)
    ax1.add_patch(cir1)
    print len(x)
    print x1
    ax1.set_title('Scatter Plot')
    plt.xlabel('X')
    plt.ylabel('Y')  
    ax1.scatter(x,y,c = 'r',marker = 'o')
    plt.ion()
    plt.show()
    time.sleep(1)
    plt.close()
    return 'ok'

enter image description here

Cache Staheli
  • 3,510
  • 7
  • 32
  • 51
邓德全
  • 19
  • 1
  • Try [this](http://stackoverflow.com/a/11364849/5994041), maybe you need to call `fig.show()` first, otherwise it just dies. – Peter Badida Feb 24 '17 at 13:19

0 Answers0