I need to delete a barchart from the subplot, in order to plot new data on the subplot.
The code I have is as follows:
self.barcontainer = tk.Frame(self)
self.barfigure = Figure(figsize = ((7.5,6.3)),dpi = 100)
self.baraxes = self.barfigure.add_subplot(111)
self.baraxes.set_ylabel('Cases')
self.baraxes.set_xlabel('State/Region')
updateddata = confirmedstates[confirmedstates.columns[-1]]
x = np.arange(len(namelist))
self.baraxes.bar(x,updateddata, label = namelist)
self.barcanvas = FigureCanvasTkAgg(self.barfigure,self.barcontainer)
barcanvas.draw()
barcanvas.get_tk_widget().pack(side = tk.TOP, fill = tk.BOTH, expand = True)
I know that for a normal lineplot, we can remove it using axes_name.lines.remove()
, but for a bar chart, the .lines
attribute returns an empty list. How can we delete off a bar chart?