I'm currently working on my project but I'm stuck on how to make annotation using multiprocessing or threading in matplotlib.
I want to display an interval of values inside each annotation that keep counting from the beginning of interval up to the top, I'm sure that there is a simple way to do this but I just can't figure it out.
I also have a problem with the ranges where the start value > end value cause the range doesn't work on it!
Here is what I've tried to do so far.
data0=rd.sample(range(100),20)
data1=rd.sample(range(100),20)
print(data0,'\n',data1)
Ranges = [range(y, n) for y,n in zip(data0, data1)]
fig = plt.figure(figsize=(11,6))#, facecolor="skyblue")
axes = plt.gca()
x = arange(20)
y = data0
bars = plt.barh(x, y, height=.8)
def worker(item):
for j in item:
ann=axes.text(bar.get_width(), bar.get_y(), '', ha='left', va='bottom',fontsize=10)
ann.set_text(j)
#plt.pause(.0000000000001)
pool = ThreadPool(20)
for bar, ran in zip(bars, Ranges):
Result=pool.map(worker, (ran,))
pool.close()
pool.join()
plt.show()
I tried to use plt.clear()
and plt.pause()
inside of the worker but it just keep throwing the msg the main thread is not on the main loop.
What should I do to solve this problem?