SourceForge logo
SourceForge logo
Menu

How to plot multiple images on the same graph using FigurecanvasTkAgg

From: aishwarya s. <ais...@gm...> - 2018年05月16日 14:21:28
Dear all,
I wanted to reciprocate the effect of :
 import matplotlib.pyplot as plt}
 plt.imshow(image1)
 plt.pause(0.7)
 plt.imshow(image2)
in a code making use of Tkinter and FigureCanvastkAgg;
Which lookes something like this :
f = Figure(figsize=(6,6))
 a = f.add_subplot(111)
 image = np.array(np.random.random((1024,1024))*100,dtype=int)
 a.imshow(image)
 canvas = FigureCanvasTkAgg(f, self)
 canvas.show()
 canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)`
If I want to plot another image2 in the same graph. How could I do it?
I tried another method but was not able to obtain the desired output:
> ​
>
 self.i = 0
 def Plot():
 print self.i
 self.f = Figure(figsize=(6,6))
 self.a = self.f.add_subplot(111)
 image = np.array(np.random.random((1024,1024))*100,dtype=int)
>
> if self.i <20:
 self.i = self.i+1
 self.a.imshow(image)
 self.canvas = FigureCanvasTkAgg(self.f, self)
 self.canvas.show()
 self.parent.after(500,Plot)
 Plot()
>
>
 self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH,
> expand=True)
 toolbar = NavigationToolbar2TkAgg(self.canvas, self)
 toolbar.update()
 self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
​
>
>
Awaiting your reply.
-- 
Regards,
Aishwarya Selvaraj

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /