Ralph Kube wrote: > Hey everybody, > thank you for your answers. I use matplotlib from qt4 now. What I do is > creating a widget in a gui and using this for plotting. The plot is to > refreshed by clicking on a button. This works perfectly fine, > until I start adding a colorbar to the plot. > When I add the colorbar and replot the whole thing, the plot doesnt > fill up the area of the widget in the gui, but roughly 80% of the > horizontal extent of the last plot. So when I replot in the axes, my > plot shrinks around 20% horizontally every time I click on the button. > I found out how to delete the old colorbar, but where do I tell > matplotlib to plot into the whole extent of the plot?
The colorbar method or pyplot function optionally resizes the image axes and uses the liberated space to make an axes for itself. For your application, you don't want to use this option; you need to make the axes object manually and use the cax kwarg to tell colorbar to use it. Or you could generate it automatically the first time, and then reuse it for all subsequent colorbar calls. Eric > > > This is the widget i instantiate in my gui: > > > class MyMplCanvas(FigureCanvas): > def __init__(self, parent=None, width = 10, height = 12, dpi = 100, > sharex = None, sharey = None): > self.fig = Figure(figsize = (width, height), dpi=dpi, facecolor = > '#FFFFFF') > self.ax = self.fig.add_subplot(111, sharex = sharex, sharey = sharey) > self.fig.subplots_adjust(left=0.1, bottom=0.15, right=0.9, top=0.9) > self.xtitle="x [a.u.]" > self.ytitle="y [a.u.]" > self.PlotTitle = "" > self.grid_status = True > self.xaxis_style = 'linear' > self.yaxis_style = 'linear' > self.format_labels() > self.ax.hold(False) > ....... > > > And this would be the code I call for plotting: > > elif self.ui.radioButton_theta.isChecked() : > data = N.vstack([ self.data_theta[self.nx/2:,:,self.filepos], > self.data_theta[:self.nx/2,:,self.filepos]] ) > title_str = 'Theta T.%03d' % self.filepos > > self.ui.widget.canvas.ax.collections = [] > plt = self.ui.widget.canvas.ax.contourf(data) > self.ui.widget.canvas.fig.colorbar(plt) > self.ui.widget.canvas.PlotTitle = title_str > self.ui.widget.canvas.print_figure('plot') > > I thought the call self.ui.widget.canvas.ax.collections = [] clears the > axes. Any ideas? > > Cheers, Ralph > > > Eric Firing wrote: >> Matthias Michler wrote: >>> Hi Ralph, >>> >>> I don't think there exists a function like the line-'set_data'-method for >>> collections, which are generated by 'contour'. This particular method of >>> lines only changes the data but leave anything else unchanged. >>> I attached an easy approach of updating a contour plot (simply deleting old >>> collections), but I'm not sure that this is the best solution. >> I don't think you area gaining anything at all by manually deleting the >> collections. Better to just clear the axes, or clear the figure, and >> make a fresh plot. >> >> Eric >> >> >>> Kind regards, >>> Matthias >>> >>> On Monday 28 September 2009 13:52:42 Ralph Kube wrote: >>>> Hi, >>>> is there a way to update a contour plot? I need to display a series of >>>> contour plots from a directory with data files and want to view them >>>> consecutively, preferrably without building a gui for it. Is there an >>>> easy way out? >>>> >>>> Cheers, Ralph > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users