SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(5)
2
(6)
3
(4)
4
(9)
5
(7)
6
(16)
7
(5)
8
(10)
9
(2)
10
(3)
11
(9)
12
(1)
13
(13)
14
(1)
15
(13)
16
(5)
17
(3)
18
(14)
19
(17)
20
(14)
21
(15)
22
(6)
23
(6)
24
25
(4)
26
(4)
27
(4)
28
(11)
29
(7)
30
(1)

Showing 6 results of 6

From: Michael S. <elm...@gm...> - 2011年04月22日 20:00:17
Great, thanks for the fix, works great now!
--Michael
On Fri, Apr 22, 2011 at 2:17 PM, Goyo <goy...@gm...> wrote:
> 2011年4月22日 Michael Schmidt <elm...@gm...>:
>> Hi Everyone,
>>
>> I'm running into a problem with updating a plot that I've embedded into a Tk
>> application. [...] I'd like the plot to
>> refresh when the button is clicked
>
> pyplot.draw() does not work here (I don't know if this is intended
> behavoir of pyplot, but it makes some sense). Using canvas.draw()
> fixes your program in my mpl setup.
>
> Goyo
>
From: Goyo <goy...@gm...> - 2011年04月22日 19:17:22
2011年4月22日 Michael Schmidt <elm...@gm...>:
> Hi Everyone,
>
> I'm running into a problem with updating a plot that I've embedded into a Tk
> application. [...] I'd like the plot to
> refresh when the button is clicked
pyplot.draw() does not work here (I don't know if this is intended
behavoir of pyplot, but it makes some sense). Using canvas.draw()
fixes your program in my mpl setup.
Goyo
From: Eric F. <ef...@ha...> - 2011年04月22日 19:13:09
On 04/22/2011 06:47 AM, Paul Ivanov wrote:
> Jason Heeris, on 2011年04月23日 00:29, wrote:
>> On 22 April 2011 03:56, Paul Ivanov<piv...@gm...> wrote:
>>> Thanks for the report, Jason. It's a bug - could you please file
>>> a bug report, so we can keep track of it?
>>
>> Will do, thanks for the workarounds :)
>>
>>> or if it's an option, use gtkagg, which doesn't suffer from the crash.
>>>
>>> from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
>>> as FigureCanvasGTK
>>
>> Just out of interest, what's the difference between GTK and GTKAgg?
>
> The FAQ has a nice summary:
>
> The canonical renderer for user interfaces is Agg which uses the
> Anti-Grain Geometry C++ library to make a raster (pixel) image of
> the figure. All of the user interfaces can be used with agg
> rendering, eg WXAgg, GTKAgg, QTAgg, TkAgg, CocoaAgg. In addition,
> some of the user interfaces support other rendering engines. For
> example, with GTK, you can also select GDK rendering (backend
> GTK) or Cairo rendering (backend GTKCairo).
>
> http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend
>
> There are also two tables at the end of that answer which list
> the renderers, and the user interface + renderer combinations.
Note that the gtk and wx backends (that is, no Agg) are not recommended. 
 They are not well maintained and may have various limitations and 
bugs. Their only potential advantage, as far as I know, is that they 
involve less network traffic when working remotely via X.
Eric
>
> best,
From: Paul I. <piv...@gm...> - 2011年04月22日 16:47:22
Jason Heeris, on 2011年04月23日 00:29, wrote:
> On 22 April 2011 03:56, Paul Ivanov <piv...@gm...> wrote:
> > Thanks for the report, Jason. It's a bug - could you please file
> > a bug report, so we can keep track of it?
> 
> Will do, thanks for the workarounds :)
> 
> > or if it's an option, use gtkagg, which doesn't suffer from the crash.
> >
> > from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
> > as FigureCanvasGTK
> 
> Just out of interest, what's the difference between GTK and GTKAgg?
The FAQ has a nice summary:
 The canonical renderer for user interfaces is Agg which uses the
 Anti-Grain Geometry C++ library to make a raster (pixel) image of
 the figure. All of the user interfaces can be used with agg
 rendering, eg WXAgg, GTKAgg, QTAgg, TkAgg, CocoaAgg. In addition,
 some of the user interfaces support other rendering engines. For
 example, with GTK, you can also select GDK rendering (backend
 GTK) or Cairo rendering (backend GTKCairo).
http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend
There are also two tables at the end of that answer which list
the renderers, and the user interface + renderer combinations.
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2011年04月22日 16:29:41
On 22 April 2011 03:56, Paul Ivanov <piv...@gm...> wrote:
> Thanks for the report, Jason. It's a bug - could you please file
> a bug report, so we can keep track of it?
Will do, thanks for the workarounds :)
> or if it's an option, use gtkagg, which doesn't suffer from the crash.
>
> from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
> as FigureCanvasGTK
Just out of interest, what's the difference between GTK and GTKAgg?
— Jason
From: Michael S. <elm...@gm...> - 2011年04月22日 04:25:12
Attachments: embed_test.py
Hi Everyone,
I'm running into a problem with updating a plot that I've embedded
into a Tk application. I'm attaching the code with this email (and
pasting it at the end, in a hopefully un-gmail-formatted-form). This
is a very simple program, with one canvas embedded into a window, with
one menu and one button Tk widgets that I'm using to select what plot
type to display. The data are x, y, and t variables, with x and y
given by cos(2*pi*t) and sin(2*pi*t) respectively. I'd like to be
able to switch between a single scatter plot and two x(t) and y(t)
plots. The program "works" in that when you resize the window, the
plot updates, however, this really isn't workable. I'd like the plot
to refresh right when the button is clicked, and I can't seem to get
it to work, nor could I find support in previous email archives.
It seems like the trick used for animations, that is, only calling
'plot' once and simply changing the xdata and ydata values of the line
would speed things up significantly, so I've implemented that in the
code, but it doesn't help.
Any help would be much appreciated! Thanks in advance.
--Michael
#!/usr/bin/env python
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as P
import matplotlib.mlab as M
import matplotlib
import numpy as N
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg as FigureCanvas
from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg
as NavigationToolbar
from matplotlib.figure import Figure
from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
from matplotlib.widgets import Button as mButton
from matplotlib.widgets import CheckButtons
import os, sys, Tkinter
import tkFileDialog
import Tkconstants as Tkc
t = N.linspace(0, 10, 1e3)
x = N.cos(2*N.pi*t)
y = N.sin(2*N.pi*t)
class window(Tkinter.Tk):
 def __init__(self, parent):
 Tkinter.Tk.__init__(self, parent)
 self.protocol('WM_DELETE_WINDOW', self._kill)
 self._create_widgets()
 def _kill(self):
 self.destroy()
 sys.exit()
 def _create_widgets(self):
 self._create_canvas()
 self._create_toolbar()
 self._create_menu()
 return
 def _create_toolbar(self):
 self.toolbar = NavigationToolbar(self.canvas, self)
 self.toolbar.update()
 self.canvas._tkcanvas.pack()
 #self.toolbar.pack()
 return
 def _create_canvas(self):
 self.fig = P.figure()
 self.fig = P.figure(figsize=(7,7))
 self.axes = []
 self.axes.append( self.fig.add_subplot(111) )
 self.axes.append( self.fig.add_subplot(211) )
 self.axes.append( self.fig.add_subplot(212) )
 self.axes[0].set_visible(True)
 self.axes[1].set_visible(False)
 self.axes[2].set_visible(False)
 self.lines = []
 self.lines.append( self.axes[0].plot([0.],[0.], '.')[0] )
 self.lines.append( self.axes[1].plot([0.],[0.], '.')[0] )
 self.lines.append( self.axes[2].plot([0.],[0.], '.')[0] )
 self.fig.subplots_adjust(bottom=0.175)
 self.frame = Tkinter.Frame(self)
 self.frame.pack(padx=0, pady=0)
 self.canvas = FigureCanvas(self.fig, master=self.frame)
 self.canvas.show()
 self.canvas.get_tk_widget().pack(side='top', fill='both')
 #self.canvas._tkcanvas.pack(side='top', fill='both', expand=1)
 return
 def _plot_it(self):
 print "hello"
 print "which_one: ", self.menu_val.get()
 if self.menu_val.get() == self.items[0]:
 print "in one"
 self.axes[0].set_visible(True)
 self.axes[1].set_visible(False)
 self.axes[2].set_visible(False)
 self.lines[0].set_xdata(x)
 self.lines[0].set_ydata(y)
 self.axes[0].set_xlabel('x')
 self.axes[0].set_ylabel('y')
 self.axes[0].set_xlim([min(x), max(x)])
 self.axes[0].set_ylim([min(y), max(y)])
 print "x: ", N.min(x), N.max(x)
 print "y: ", N.min(y), N.max(y)
 P.draw()
 else:
 self.axes[0].set_visible(False)
 self.axes[1].set_visible(True)
 self.axes[2].set_visible(True)
 self.lines[1].set_xdata(t)
 self.lines[1].set_ydata(x)
 self.lines[2].set_xdata(t)
 self.lines[2].set_ydata(x)
 self.axes[1].set_ylabel('x(t)')
 self.axes[1].set_xlim([N.min(t), N.max(t)])
 self.axes[1].set_ylim([N.min(x), N.max(x)])
 self.axes[2].set_ylabel('y(t)')
 self.axes[2].set_xlim([N.min(t), N.max(t)])
 self.axes[2].set_ylim([N.min(y), N.max(y)])
 self.axes[2].set_xlabel('t')
 P.draw()
 def _create_menu(self):
 self.items = ['scatter', 'strip']
 self.menu_val = Tkinter.StringVar()
 self.menu_val.set(self.items[0])
 self.button_menu_frame = Tkinter.Frame(self)
 def click(): print "click!"
 self.button = Tkinter.Button(self.button_menu_frame,
text='plot', command=self._plot_it)
 self.button.pack(side='top', ipadx=63, fill='both')
 self.menu_frame = Tkinter.Frame(self.button_menu_frame)
 #self.menu_frame.pack(side='left', ipadx=20, expand=1, fill='both')
 self.menu = Tkinter.OptionMenu(self.menu_frame, self.menu_val,
*self.items)
 self.menu.pack(side='left', anchor=Tkc.SW, ipadx=20, expand=1,
fill='both')
 self.menu_frame.pack(side='top', fill='both')
 self.button_menu_frame.pack(side='left', fill='both')
 return
if __name__ == "__main__":
 app = window(None)
 app.title('Analysis')
 #app.pack_propegate(0)
 app.mainloop()

Showing 6 results of 6

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 によって変換されたページ (->オリジナル) /