[Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong).Many thanksDavidCode below: from gi.repository import Gtk, Gdk, GLibfrom matplotlib.figure import Figure# Tell matplotlib to use a GTK canvas for drawing#from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvasfrom matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas# Application Classclass pyMatPlotLibTest(object):def update_gui(self):y = [self.index] * 1024self.index += 1if self.index 1024: self.index = 0 Gdk.threads_enter()self.line.set_ydata(y) self.axes.set_title(%d % self.index)self.canvas.draw() Gdk.threads_leave()return Truedef __init__(self): self.index = 0self.x = range(1024)# Initialise the threads system and allow threads to work with GTKGLib.threads_init() # Draw scopeself.figure = Figure(dpi=100)self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea #self.widget.alignment_ScopeDisplay.add(self.canvas)# Draw initial scopeself.axes = self.figure.add_subplot(111)self.line, = self.axes.plot(self.x, [0]* 1024)self.axes.set_title(None) self.axes.set_xbound(0.0, 1024)self.axes.set_ybound(-16, 1040) self.window_main = Gtk.Window(title=pyMatPlotLibTest) self.window_main.connect(destroy, lambda x: Gtk.main_quit()) self.window_main.add(self.canvas)self.window_main.show_all() # Ticker for the update of the input state monitoring Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, interval = 10, # msecfunction = self.update_gui)Gtk.main()if __name__ == __main__:gui = pyMatPlotLibTest() -- View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html Sent from the matplotlib - users mailing list archive at Nabble.com.-- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Plotting a imshow() image in 3d in matplotlib
Hi, How to plot a imshow() image in 3d axes? I was trying with this post http://stackoverflow.com/a/25295272/4920782. In that post, the surface plot looks same as imshow() plot but actually they are not. To demonstrate, here I took different data: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np # create a 21 x 21 vertex mesh xx, yy = np.meshgrid(np.linspace(0,1,21), np.linspace(0,1,21)) # create vertices for a rotated mesh (3D rotation matrix) X = xx Y = yy Z = 10*np.ones(X.shape) # create some dummy data (20 x 20) for the image data = np.cos(xx) * np.cos(xx) + np.sin(yy) * np.sin(yy) # create the figure fig = plt.figure() # show the reference image ax1 = fig.add_subplot(121) ax1.imshow(data, cmap=plt.cm.BrBG, interpolation='nearest', origin='lower', extent=[0,1,0,1]) # show the 3D rotated projection ax2 = fig.add_subplot(122, projection='3d') ax2.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False) The plots are here http://www.physics.iitm.ac.in/%7Eraj/imshow_plot_surface.png. Is there any other way to solve this issue? I have posted this question http://stackoverflow.com/questions/30464117/plotting-a-imshow-image-in-3d-in-matplotlib on stackoverflow. Thanks Raj -- ## Raj Kumar Manna Complex Fluid Biological Physics Lab IIT Madras Ph. No. 8144637401 alternate email: r...@physics.iitm.ac.in rajphysics@gmail.com -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
I removed all calls to threads and swapped Gdk.threads_add_timeout to Glib.timeout_add (See attached. However if I comment the call to self.canvas.draw(), the python memory utilisation sits at 30.8Mb. from gi.repository import Gtk, Gdk, GLib from matplotlib.figure import Figure # Tell matplotlib to use a GTK canvas for drawing #from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas # Application Class class pyMatPlotLibTest(object): def update_gui(self): y = [self.index] * 1024 self.index += 1 if self.index 1024: self.index = 0 #Gdk.threads_enter() self.line.set_ydata(y) self.axes.set_title(%d % self.index) self.canvas.draw() #Gdk.threads_leave() return True def __init__(self): self.index = 0 self.x = range(1024) # Initialise the threads system and allow threads to work with GTK #GLib.threads_init() # Draw scope self.figure = Figure(dpi=100) self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea #self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial scope self.axes = self.figure.add_subplot(111) self.line, = self.axes.plot(self.x, [0]* 1024) self.axes.set_title(None) self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040) self.window_main = Gtk.Window(title=pyMatPlotLibTest) self.window_main.connect(destroy, lambda x: Gtk.main_quit()) self.window_main.add(self.canvas) self.window_main.show_all() # Ticker for the update of the input state monitoring GLib.timeout_add(10, self.update_gui) #Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, #interval = 10, # msec #function = self.update_gui) Gtk.main() if __name__ == __main__: gui = pyMatPlotLibTest() From: ben.v.r...@gmail.com [mailto:ben.v.r...@gmail.com] On Behalf Of Benjamin Root Sent: 26 May 2015 14:53 To: David Hughes Cc: Matplotlib Users Subject: Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak I take it that it doesn't happen using the GTK3Agg backend? What about the threading portion? Does it happen if you take the threading out? Ben Root On Tue, May 26, 2015 at 8:23 AM, David dhug...@rapiscansystems.commailto:dhug...@rapiscansystems.com wrote: Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong). Many thanks David Code below: from gi.repository import Gtk, Gdk, GLib from matplotlib.figure import Figure # Tell matplotlib to use a GTK canvas for drawing #from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas # Application Class class pyMatPlotLibTest(object): def update_gui(self): y = [self.index] * 1024 self.index += 1 if self.index 1024: self.index = 0 Gdk.threads_enter() self.line.set_ydata(y) self.axes.set_title(%d % self.index) self.canvas.draw() Gdk.threads_leave() return True def __init__(self): self.index = 0 self.x = range(1024) # Initialise the threads system and allow threads to work with GTK GLib.threads_init() # Draw scope self.figure = Figure(dpi=100) self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea #self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial scope self.axes = self.figure.add_subplot(111) self.line, = self.axes.plot(self.x, [0]* 1024) self.axes.set_title(None) self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040) self.window_main = Gtk.Window(title=pyMatPlotLibTest) self.window_main.connect(destroy, lambda x: Gtk.main_quit()) self.window_main.add(self.canvas) self.window_main.show_all() # Ticker for the update of the input state monitoring Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, interval = 10, # msec function = self.update_gui) Gtk.main() if __name__ == __main__: gui = pyMatPlotLibTest() View
Re: [Matplotlib-users] Annotate not Drawing Properly in a Gridspec - Version 1.4.3
Sterling, Thanks for the pointer. I've already used a workaround where I used data coordinates and put it at: 0.9 * (xmax - xmin) + xmin, and similar for y. I'm really only reporting this so that it can be fixed if there is someone who does need to annotate something in a grid. Sean On May 26, 2015, at 11:54, Sterling Smith smit...@fusion.gat.com wrote: Sean, Do you need an `annotate`, or just a `text`? `text` has the `transform` keyword, to which you can pass `ax.transAxes`. ax.text(.9,.9, r$\mathbf{ + lab + )}$”,transform=ax.transAxes,ha=‘right’,va=‘center’) -Sterling On May 26, 2015, at 10:06AM, Sean Lake odysseus9...@gmail.com wrote: Hello all, I'm using matplotlib 1.4.3 installed using fink with python 2.7. I'm trying to produce a grid of plots using gridspec that has annotations to label each plot. Here is the call to annotate the current axes: ax.annotate( r$\mathbf{ + lab + )}$, xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)), xytext=(0.9, 0.9), textcoords=axes fraction, fontsize=14 ) Where ax is initialized by: ax = plt.subplot(gs[ coords[0], coords[1] ]) and gs by: gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 ) The trouble comes in when abs(ymax) abs(ymin). When that is true, the labels are offset upward by one row, for some reason. I've attached a script that demonstrates the problem, and an example of the output. I can work around this problem by using data coordinates, but even so this reveals a bug somewhere. Thanks, Sean Lake BugDemo.pyBugDemo.pdf-- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Annotate not Drawing Properly in a Gridspec - Version 1.4.3
I think this is a feature/bug that got reverted in the master branch. Perhaps you could try building matplotlib from source and seeing if the problem goes away? Cheers! Ben Root On Tue, May 26, 2015 at 3:00 PM, Sean Lake odysseus9...@gmail.com wrote: Sterling, Thanks for the pointer. I've already used a workaround where I used data coordinates and put it at: 0.9 * (xmax - xmin) + xmin, and similar for y. I'm really only reporting this so that it can be fixed if there is someone who does need to annotate something in a grid. Sean On May 26, 2015, at 11:54, Sterling Smith smit...@fusion.gat.com wrote: Sean, Do you need an `annotate`, or just a `text`? `text` has the `transform` keyword, to which you can pass `ax.transAxes`. ax.text(.9,.9, r$\mathbf{ + lab + )}$”,transform=ax.transAxes,ha=‘right’,va=‘center’) -Sterling On May 26, 2015, at 10:06AM, Sean Lake odysseus9...@gmail.com wrote: Hello all, I'm using matplotlib 1.4.3 installed using fink with python 2.7. I'm trying to produce a grid of plots using gridspec that has annotations to label each plot. Here is the call to annotate the current axes: ax.annotate( r$\mathbf{ + lab + )}$, xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)), xytext=(0.9, 0.9), textcoords=axes fraction, fontsize=14 ) Where ax is initialized by: ax = plt.subplot(gs[ coords[0], coords[1] ]) and gs by: gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 ) The trouble comes in when abs(ymax) abs(ymin). When that is true, the labels are offset upward by one row, for some reason. I've attached a script that demonstrates the problem, and an example of the output. I can work around this problem by using data coordinates, but even so this reveals a bug somewhere. Thanks, Sean Lake BugDemo.pyBugDemo.pdf-- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] configure subplots feature request
I'm plotting 1 figure with 8 subplots. They are 8 channels, and I want to see if there is some interaction. I wish that the 'configure subplots' menu allowed me to choose just some subplots to display (resizing when I turn some off), so I could get a better view at the selected subplots. -- Those who fail to understand recursion are doomed to repeat it -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
I take it that it doesn't happen using the GTK3Agg backend? GTK3Agg is unimplemented at the GTK3-end: File c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py, line 69, in on_draw_event buf, cairo.FORMAT_ARGB32, width, height) NotImplementedError: Surface.create_for_data: Not Implemented yet. What about the threading portion? Does it happen if you take the threading out? I removed all calls to threads and swapped Gdk.threads_add_timeout to Glib.timeout_add. This made little difference. However if I comment the call to self.canvas.draw(), the python memory utilisation sits at 30.8Mb (but the graph does not update of course). Thanks David -- View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614p45616.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
Thanks, however GTK3Agg is unimplemented in at the GTK3-end: File c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py, line 69, in on_draw_event buf, cairo.FORMAT_ARGB32, width, height) NotImplementedError: Surface.create_for_data: Not Implemented yet. Regards David From: ben.v.r...@gmail.com [mailto:ben.v.r...@gmail.com] On Behalf Of Benjamin Root Sent: 26 May 2015 14:53 To: David Hughes Cc: Matplotlib Users Subject: Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak I take it that it doesn't happen using the GTK3Agg backend? What about the threading portion? Does it happen if you take the threading out? Ben Root On Tue, May 26, 2015 at 8:23 AM, David dhug...@rapiscansystems.commailto:dhug...@rapiscansystems.com wrote: Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong). Many thanks David Code below: from gi.repository import Gtk, Gdk, GLib from matplotlib.figure import Figure # Tell matplotlib to use a GTK canvas for drawing #from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas # Application Class class pyMatPlotLibTest(object): def update_gui(self): y = [self.index] * 1024 self.index += 1 if self.index 1024: self.index = 0 Gdk.threads_enter() self.line.set_ydata(y) self.axes.set_title(%d % self.index) self.canvas.draw() Gdk.threads_leave() return True def __init__(self): self.index = 0 self.x = range(1024) # Initialise the threads system and allow threads to work with GTK GLib.threads_init() # Draw scope self.figure = Figure(dpi=100) self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea #self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial scope self.axes = self.figure.add_subplot(111) self.line, = self.axes.plot(self.x, [0]* 1024) self.axes.set_title(None) self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040) self.window_main = Gtk.Window(title=pyMatPlotLibTest) self.window_main.connect(destroy, lambda x: Gtk.main_quit()) self.window_main.add(self.canvas) self.window_main.show_all() # Ticker for the update of the input state monitoring Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, interval = 10, # msec function = self.update_gui) Gtk.main() if __name__ == __main__: gui = pyMatPlotLibTest() View this message in context: matplotlib.backends.backend_gtk3cairo memory leakhttp://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html Sent from the matplotlib - users mailing list archivehttp://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html at Nabble.com. -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.netmailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
I take it that it doesn't happen using the GTK3Agg backend? What about the threading portion? Does it happen if you take the threading out? Ben Root On Tue, May 26, 2015 at 8:23 AM, David dhug...@rapiscansystems.com wrote: Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong). Many thanks David Code below: from gi.repository import Gtk, Gdk, GLib from matplotlib.figure import Figure # Tell matplotlib to use a GTK canvas for drawing #from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas # Application Class class pyMatPlotLibTest(object): def update_gui(self): y = [self.index] * 1024 self.index += 1 if self.index 1024: self.index = 0 Gdk.threads_enter() self.line.set_ydata(y) self.axes.set_title(%d % self.index) self.canvas.draw() Gdk.threads_leave() return True def __init__(self): self.index = 0 self.x = range(1024) # Initialise the threads system and allow threads to work with GTK GLib.threads_init() # Draw scope self.figure = Figure(dpi=100) self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea #self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial scope self.axes = self.figure.add_subplot(111) self.line, = self.axes.plot(self.x, [0]* 1024) self.axes.set_title(None) self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040) self.window_main = Gtk.Window(title=pyMatPlotLibTest) self.window_main.connect(destroy, lambda x: Gtk.main_quit()) self.window_main.add(self.canvas) self.window_main.show_all() # Ticker for the update of the input state monitoring Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, interval = 10, # msec function = self.update_gui) Gtk.main() if __name__ == __main__: gui = pyMatPlotLibTest() -- View this message in context: matplotlib.backends.backend_gtk3cairo memory leak http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html Sent from the matplotlib - users mailing list archive http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html at Nabble.com. -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Annotate not Drawing Properly in a Gridspec - Version 1.4.3
Hello all, I'm using matplotlib 1.4.3 installed using fink with python 2.7. I'm trying to produce a grid of plots using gridspec that has annotations to label each plot. Here is the call to annotate the current axes: ax.annotate( r$\mathbf{ + lab + )}$, xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)), xytext=(0.9, 0.9), textcoords=axes fraction, fontsize=14 ) Where ax is initialized by: ax = plt.subplot(gs[ coords[0], coords[1] ]) and gs by: gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 ) The trouble comes in when abs(ymax) abs(ymin). When that is true, the labels are offset upward by one row, for some reason. I've attached a script that demonstrates the problem, and an example of the output. I can work around this problem by using data coordinates, but even so this reveals a bug somewhere. Thanks, Sean Lake #!/sw/bin/python2.7 import matplotlib matplotlib.use( Agg ) import matplotlib.figure as pltfig import matplotlib.pyplot as plt import matplotlib.gridspec as mpgs plt.close(all) #plot grid plt.close() plt.figure( figsize=(6.5, 9.0), subplotpars=pltfig.SubplotParams( top=0.95, left=0.1, bottom=0.08, right=0.98 )) gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 ) PlotOrder = [ (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1) ] panellabels = [ a, b, c, d, e, f ] xmin, xmax = (-3.0, 3.0) ymin, ymax = (-5.0, 5.0) #This works fine ymin, ymax = (-5.0, 4.999) #This breaks the labeling for coords, label in zip( PlotOrder, panellabels ): ax = plt.subplot(gs[ coords[0], coords[1] ]) ax.set_xlim( (xmin, xmax) ) ax.set_ylim( (ymin, ymax) ) ax.annotate( r$\mathbf{ + label + )}$, xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)), xytext=(0.9, 0.9), textcoords=axes fraction, fontsize=14 ) plt.savefig( BugDemo.pdf, fmt=pdf ) BugDemo.pdf Description: Adobe PDF document -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
IGtk3Agg should work in you use cairocffi instead of py(2/3)cairo. AFAIK py(2/3)cairo is more or less unmaintained these days and that function has never been implemented in a released version. Best Jens tir. 26. maj 2015 kl. 16.27 skrev David dhug...@rapiscansystems.com: I take it that it doesn't happen using the GTK3Agg backend? GTK3Agg is unimplemented at the GTK3-end: File c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py, line 69, in on_draw_event buf, cairo.FORMAT_ARGB32, width, height) NotImplementedError: Surface.create_for_data: Not Implemented yet. What about the threading portion? Does it happen if you take the threading out? I removed all calls to threads and swapped Gdk.threads_add_timeout to Glib.timeout_add. This made little difference. However if I comment the call to self.canvas.draw(), the python memory utilisation sits at 30.8Mb (but the graph does not update of course). Thanks David -- View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614p45616.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting a imshow() image in 3d in matplotlib
On Tue, May 26, 2015 at 12:36 PM, Raj Kumar Manna rajphysics@gmail.com wrote: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np # create a 21 x 21 vertex mesh xx, yy = np.meshgrid(np.linspace(0,1,21), np.linspace(0,1,21)) # create vertices for a rotated mesh (3D rotation matrix) X = xx Y = yy Z = 10*np.ones(X.shape) # create some dummy data (20 x 20) for the image data = np.cos(xx) * np.cos(xx) + np.sin(yy) * np.sin(yy) # create the figure fig = plt.figure() # show the reference image ax1 = fig.add_subplot(121) ax1.imshow(data, cmap=plt.cm.BrBG, interpolation='nearest', origin='lower', extent=[0,1,0,1]) # show the 3D rotated projection ax2 = fig.add_subplot(122, projection='3d') ax2.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False) The call to imshow() without vmin/vmax arguments will automatically scale the colormap to cover the entire range of values. Meanwhile, when you did plt.cm.BrBG(data), it assumed that the vmin/vmax is 0 and 1, respectively. The min and max of your data is actually 0.292 and 1.708. If you normalize your data, it should look much more correct. Cheers! Ben Root -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users