SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Ralph K. <ral...@go...> - 2009年09月28日 12:09:44
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
From: Ralph K. <rk...@po...> - 2009年09月28日 11:34:04
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
From: John [H2O] <was...@gm...> - 2009年09月28日 21:17:47
Ralph Kube-2 wrote:
> 
> 
> Is there an 
> easy way out?
> 
> 
Well, you could just script it and create .png files.... I do it all the
time.
-- 
View this message in context: http://www.nabble.com/Update-a-contour-plot-tp25648878p25653140.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Eric F. <ef...@ha...> - 2009年09月29日 17:44:57
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&reg; 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&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Ralph K. <ral...@go...> - 2009年09月30日 10:12:35
Hey Eric,
> 
> 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.
this is exactly what I worked out ;)
I create the first colorbar and save the axis object it plots itself in:
	self.colorbar = self.ui.widget.canvas.fig.colorbar(plt, ax = 
self.ui.widget.canvas.ax.get_axes())
Then I plot each new colorbar into that axes object by specifying the 
cax keyword via
	self.ui.widget.canvas.fig.colorbar(plt, cax = self.colorbar.ax)
Thank you for your help.
Cheers, Ralph
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 によって変換されたページ (->オリジナル) /