Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## matplotlib-users

 [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Paul Leopardi - 2011-02-06 04:54:58 ```Hi all, I'm having trouble using multiple figures with mplot3d. Once each new figure is plotted, the plots from new figure is also displayed in all of the old figures. For example, once the plot for figure 2 has finished, the plot fo figure 1 is replaced by a copy of the plot for figure 2, and so on... I have included an abbreviated version of my script code. My original code uses Cython and my GluCat library, but I am fairly sure the cause of the problem lies either with mplot3d or with my Python script code. I am using openSUSE 11.2 with python-base-2.6.2-6.7.1.x86_64 python-matplotlib-1.0.1-20.1.x86_64 python-matplotlib-tk-1.0.1-20.1.x86_64 python-matplotlib-wx-1.0.1-20.1.x86_64 Best, Paul Script excerpt: ... from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt ... # Plot C curves. for i in xrange(0,C): ... # Use a new figure for each curve. fig=plt.figure(figsize=(15,12)) ax = fig.gca(projection='3d') plt.show() ... # Split the curve into M segments, each with an appropriate colour. for j in range(0,M): # Find N points forming a curve segment ... # Determine the colour of the curve segment... # Plot the curve segment using the chosen colour. alow=(abot-1 if j>0 else abot) ax.plot(x[0,alow:atop],x[1,alow:atop],x[2,alow:atop],c=rgb.tolist()) plt.draw() plt.show() ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Benjamin Root - 2011-02-06 18:16:00 Attachments: Message as HTML ```On Sat, Feb 5, 2011 at 10:54 PM, Paul Leopardi wrote: > Hi all, > I'm having trouble using multiple figures with mplot3d. Once each new > figure > is plotted, the plots from new figure is also displayed in all of the old > figures. For example, once the plot for figure 2 has finished, the plot fo > figure 1 is replaced by a copy of the plot for figure 2, and so on... > I have included an abbreviated version of my script code. My original code > uses Cython and my GluCat library, but I am fairly sure the cause of the > problem lies either with mplot3d or with my Python script code. > > I am using openSUSE 11.2 with > python-base-2.6.2-6.7.1.x86_64 > python-matplotlib-1.0.1-20.1.x86_64 > python-matplotlib-tk-1.0.1-20.1.x86_64 > python-matplotlib-wx-1.0.1-20.1.x86_64 > > Best, Paul > > Script excerpt: > > ... > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > ... > # Plot C curves. > for i in xrange(0,C): > ... > # Use a new figure for each curve. > fig=plt.figure(figsize=(15,12)) > ax = fig.gca(projection='3d') > plt.show() > ... > # Split the curve into M segments, each with an appropriate colour. > for j in range(0,M): > # Find N points forming a curve segment ... > # Determine the colour of the curve segment... > # Plot the curve segment using the chosen colour. > alow=(abot-1 if j>0 else abot) > ax.plot(x[0,alow:atop],x[1,alow:atop],x[2,alow:atop],c=rgb.tolist()) > plt.draw() > plt.show() > > Paul, I am not exactly sure what your sample script is trying to do. Could you please attach a short self-contained working script that demonstrates your problem? Ben Root ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Paul Leopardi - 2011-02-07 11:03:05 ```Hi all, On Sun, 6 Feb 2011 03:54:48 PM Paul Leopardi wrote: > I'm having trouble using multiple figures with mplot3d. I have appended an entire example script, below. The script incrementally plots 3 curves, one in each of 3 figure windows. The trouble is, once Figure 2 has finished plotting, the curve for Figure 1 disappears and is replaced by the curve for Figure 2, with the axes for Figure 1; once Figure 3 has finished plotting, the curves for Figures 1 and 2 disappear and are replaced by the curve for Figure 3, with the axes for Figure 1 and Figure 2, respectively. The original code was written with incremental plotting because the points took a long time to calculate. Without incremental plotting, the figures stayed blank for a long time. The script below is very similar to my original script, but does not depend on my GluCat library. Best, Paul --- # -*- coding: utf-8 -*- # Imports needed for array calculation and plotting. from numpy import array, floor, random, empty, cos, pi from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt # Constants to control the plotting. C=3 # Number of curves to plot. P=1000 # Number of points overall. R=2 # Scaling constant to use. N=25 # Number of points in a curve segment. M=P/N # Array of points. x=empty((3,P)) rgb=empty((3)) # Plot C curves. for i in xrange(0,C): # Initial point. x0=random.randn(3) # Plot a curve using a random bivector in R_{5,0} # with appropriate scaling. w=random.randn(3) * 2*pi*R/P # Use a new figure for each curve. fig=plt.figure(figsize=(15,12)) # ax=Axes3D(fig) ax = fig.gca(projection='3d') plt.show() # Coordinate limits to determine the colour of the first curve segment. minx=array([-x0[0],x0[1],-x0[2]]) maxx=minx.copy() # Split the curve into M segments, each with an appropriate colour. for j in range(0,M): # Find N points forming a curve segment by # exponentiating w*k for k from j*N to (j+1)*N-1. abot=j*N atop=abot+N for k in xrange(abot,atop): for h in range(0,3): x[h,k]=x0[h]+cos(w[h]*k) # Determine the colour of the curve segment. amid=floor((abot+atop)/2) for h in range(0,3): sign=(-1)**(h+1) minx[h]=min(minx[h],min(sign*x[h,abot:atop])) maxx[h]=max(maxx[h],max(sign*x[h,abot:atop])) rgb[h]=max(0.0,min((sign*x[h,amid]-minx[h])/(maxx[h]-minx[h]),1.0)) # Plot the curve segment using the chosen colour. alow=(abot-1 if j>0 else abot) ax.plot(x[0,alow:atop],x[1,alow:atop],x[2,alow:atop],c=rgb.tolist()) plt.draw() plt.show() ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Benjamin Root - 2011-02-08 16:15:47 Attachments: Message as HTML ```On Mon, Feb 7, 2011 at 5:02 AM, Paul Leopardi wrote: > Hi all, > On Sun, 6 Feb 2011 03:54:48 PM Paul Leopardi wrote: > > I'm having trouble using multiple figures with mplot3d. > > I have appended an entire example script, below. > > The script incrementally plots 3 curves, one in each of 3 figure windows. > The > trouble is, once Figure 2 has finished plotting, the curve for Figure 1 > disappears and is replaced by the curve for Figure 2, with the axes for > Figure > 1; once Figure 3 has finished plotting, the curves for Figures 1 and 2 > disappear and are replaced by the curve for Figure 3, with the axes for > Figure > 1 and Figure 2, respectively. > > The original code was written with incremental plotting because the points > took a long time to calculate. Without incremental plotting, the figures > stayed blank for a long time. The script below is very similar to my > original > script, but does not depend on my GluCat library. > > Best, Paul > --- > > # -*- coding: utf-8 -*- > > # Imports needed for array calculation and plotting. > from numpy import array, floor, random, empty, cos, pi > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > > # Constants to control the plotting. > C=3 # Number of curves to plot. > P=1000 # Number of points overall. > R=2 # Scaling constant to use. > N=25 # Number of points in a curve segment. > M=P/N > > # Array of points. > x=empty((3,P)) > rgb=empty((3)) > > # Plot C curves. > for i in xrange(0,C): > # Initial point. > x0=random.randn(3) > > # Plot a curve using a random bivector in R_{5,0} > # with appropriate scaling. > w=random.randn(3) * 2*pi*R/P > > # Use a new figure for each curve. > fig=plt.figure(figsize=(15,12)) > # ax=Axes3D(fig) > ax = fig.gca(projection='3d') > plt.show() > > # Coordinate limits to determine the colour of the first curve segment. > minx=array([-x0[0],x0[1],-x0[2]]) > maxx=minx.copy() > > # Split the curve into M segments, each with an appropriate colour. > for j in range(0,M): > > # Find N points forming a curve segment by > # exponentiating w*k for k from j*N to (j+1)*N-1. > abot=j*N > atop=abot+N > for k in xrange(abot,atop): > for h in range(0,3): > x[h,k]=x0[h]+cos(w[h]*k) > > # Determine the colour of the curve segment. > amid=floor((abot+atop)/2) > for h in range(0,3): > sign=(-1)**(h+1) > minx[h]=min(minx[h],min(sign*x[h,abot:atop])) > maxx[h]=max(maxx[h],max(sign*x[h,abot:atop])) > rgb[h]=max(0.0,min((sign*x[h,amid]-minx[h])/(maxx[h]-minx[h]),1.0)) > > # Plot the curve segment using the chosen colour. > alow=(abot-1 if j>0 else abot) > ax.plot(x[0,alow:atop],x[1,alow:atop],x[2,alow:atop],c=rgb.tolist()) > plt.draw() > plt.show() > > Paul, As formatted, the code would not run. I presume that everything after "for j in range(0,M):" should be indented? When I did that and ran it in ipython, I could not reproduce your problem. What version of matplotlib are you running? Ben Root ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Paul Leopardi - 2011-02-08 23:53:58 ```Hi Ben, On Wed, 9 Feb 2011 03:15:19 AM you wrote: > As formatted, the code would not run. I presume that everything after "for > j in range(0,M):" should be indented? When I did that and ran it in > ipython, I could not reproduce your problem. What version of matplotlib > are you running? Thanks for your continued close attention to this undoubted problem. Your email system mangled the indentation. The correct indentation is displayed at http://sourceforge.net/mailarchive/message.php?msg_id=27020771 I have also included a copy of the script matplotlib_bug_example.py with this message. [*Not* posted to the list.] Here is how I run it: ipython -pylab Python 2.6.2 (r262:71600, Oct 28 2010, 20:54:41) Type "copyright", "credits" or "license" for more information. IPython 0.10 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. Welcome to pylab, a matplotlib-based Python environment. For more information, type 'help(pylab)'. In [1]: run matplotlib_bug_example.py My original post http://sourceforge.net/mailarchive/message.php?msg_id=27016368 listed what I thought were the relevant versions: Quote I am using openSUSE 11.2 with python-base-2.6.2-6.7.1.x86_64 python-matplotlib-1.0.1-20.1.x86_64 python-matplotlib-tk-1.0.1-20.1.x86_64 python-matplotlib-wx-1.0.1-20.1.x86_64 Unquote I have since run the script on a second machine which uses Ubuntu Karmic, with identical results. Versions in brief: Linux linfinit 2.6.31.12-0.1-default #1 SMP PREEMPT 2010-12-10 11:18:32 +0100 x86_64 x86_64 x86_64 GNU/Linux IPython-0.10-3.2.noarch python-2.6.2-6.7.1.x86_64 python-matplotlib-1.0.1-20.1.x86_64 python-matplotlib-tk-1.0.1-20.1.x86_64 python-matplotlib-wx-1.0.1-20.1.x86_64 python-numpy-1.5.0-17.2.x86_64 python-tk-2.6.2-6.7.1.x86_64 Linux cheeze 2.6.31-22-generic #70-Ubuntu SMP Wed Dec 1 23:51:13 UTC 2010 i686 GNU/Linux ipython 0.10-1 python 2.6.4-0ubuntu1 python-matplotlib 0.99.0-1ubuntu1 python-numpy 1:1.3.0-3 python-tk 2.6.3-0ubuntu1 I have included a listing showing all versions of all packages with names containing the string "python", on both machines. [*Not* posted to the list.] Best, Paul ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Benjamin Root - 2011-02-09 02:44:15 Attachments: Message as HTML ```On Tue, Feb 8, 2011 at 5:53 PM, Paul Leopardi wrote: > Hi Ben, > On Wed, 9 Feb 2011 03:15:19 AM you wrote: > > As formatted, the code would not run. I presume that everything after > "for > > j in range(0,M):" should be indented? When I did that and ran it in > > ipython, I could not reproduce your problem. What version of matplotlib > > are you running? > > Thanks for your continued close attention to this undoubted problem. > > Your email system mangled the indentation. The correct indentation is > displayed at > http://sourceforge.net/mailarchive/message.php?msg_id=27020771 > > I have also included a copy of the script matplotlib_bug_example.py with > this > message. [*Not* posted to the list.] Here is how I run it: > > ipython -pylab > Python 2.6.2 (r262:71600, Oct 28 2010, 20:54:41) > Type "copyright", "credits" or "license" for more information. > > IPython 0.10 -- An enhanced Interactive Python. > ? -> Introduction and overview of IPython's features. > %quickref -> Quick reference. > help -> Python's own help system. > object? -> Details about 'object'. ?object also works, ?? prints more. > > Welcome to pylab, a matplotlib-based Python environment. > For more information, type 'help(pylab)'. > > In [1]: run matplotlib_bug_example.py > > My original post > http://sourceforge.net/mailarchive/message.php?msg_id=27016368 > listed what I thought were the relevant versions: > > Quote > I am using openSUSE 11.2 with > python-base-2.6.2-6.7.1.x86_64 > python-matplotlib-1.0.1-20.1.x86_64 > python-matplotlib-tk-1.0.1-20.1.x86_64 > python-matplotlib-wx-1.0.1-20.1.x86_64 > Unquote > > I have since run the script on a second machine which uses Ubuntu Karmic, > with > identical results. > > Versions in brief: > Linux linfinit 2.6.31.12-0.1-default #1 SMP PREEMPT 2010-12-10 11:18:32 > +0100 > x86_64 x86_64 x86_64 GNU/Linux > > IPython-0.10-3.2.noarch > python-2.6.2-6.7.1.x86_64 > python-matplotlib-1.0.1-20.1.x86_64 > python-matplotlib-tk-1.0.1-20.1.x86_64 > python-matplotlib-wx-1.0.1-20.1.x86_64 > python-numpy-1.5.0-17.2.x86_64 > python-tk-2.6.2-6.7.1.x86_64 > > Linux cheeze 2.6.31-22-generic #70-Ubuntu SMP Wed Dec 1 23:51:13 UTC 2010 > i686 GNU/Linux > > ipython 0.10-1 > python 2.6.4-0ubuntu1 > python-matplotlib 0.99.0-1ubuntu1 > python-numpy 1:1.3.0-3 > python-tk 2.6.3-0ubuntu1 > > > I have included a listing showing all versions of all packages with names > containing the string "python", on both machines. [*Not* posted to the > list.] > Best, Paul > > Trying out the script on another machine of mine, I was able to reproduce the problem. I will have to see what is the difference between my two computers that would cause the other one to work perfectly fine. Ben Root ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Benjamin Root - 2011-02-15 16:07:54 Attachments: Message as HTML ```On Tue, Feb 8, 2011 at 8:43 PM, Benjamin Root wrote: > On Tue, Feb 8, 2011 at 5:53 PM, Paul Leopardi wrote: > >> Hi Ben, >> On Wed, 9 Feb 2011 03:15:19 AM you wrote: >> > As formatted, the code would not run. I presume that everything after >> "for >> > j in range(0,M):" should be indented? When I did that and ran it in >> > ipython, I could not reproduce your problem. What version of matplotlib >> > are you running? >> >> Thanks for your continued close attention to this undoubted problem. >> >> Your email system mangled the indentation. The correct indentation is >> displayed at >> http://sourceforge.net/mailarchive/message.php?msg_id=27020771 >> >> I have also included a copy of the script matplotlib_bug_example.py with >> this >> message. [*Not* posted to the list.] Here is how I run it: >> >> ipython -pylab >> Python 2.6.2 (r262:71600, Oct 28 2010, 20:54:41) >> Type "copyright", "credits" or "license" for more information. >> >> IPython 0.10 -- An enhanced Interactive Python. >> ? -> Introduction and overview of IPython's features. >> %quickref -> Quick reference. >> help -> Python's own help system. >> object? -> Details about 'object'. ?object also works, ?? prints more. >> >> Welcome to pylab, a matplotlib-based Python environment. >> For more information, type 'help(pylab)'. >> >> In [1]: run matplotlib_bug_example.py >> >> My original post >> http://sourceforge.net/mailarchive/message.php?msg_id=27016368 >> listed what I thought were the relevant versions: >> >> Quote >> I am using openSUSE 11.2 with >> python-base-2.6.2-6.7.1.x86_64 >> python-matplotlib-1.0.1-20.1.x86_64 >> python-matplotlib-tk-1.0.1-20.1.x86_64 >> python-matplotlib-wx-1.0.1-20.1.x86_64 >> Unquote >> >> I have since run the script on a second machine which uses Ubuntu Karmic, >> with >> identical results. >> >> Versions in brief: >> Linux linfinit 2.6.31.12-0.1-default #1 SMP PREEMPT 2010-12-10 11:18:32 >> +0100 >> x86_64 x86_64 x86_64 GNU/Linux >> >> IPython-0.10-3.2.noarch >> python-2.6.2-6.7.1.x86_64 >> python-matplotlib-1.0.1-20.1.x86_64 >> python-matplotlib-tk-1.0.1-20.1.x86_64 >> python-matplotlib-wx-1.0.1-20.1.x86_64 >> python-numpy-1.5.0-17.2.x86_64 >> python-tk-2.6.2-6.7.1.x86_64 >> >> Linux cheeze 2.6.31-22-generic #70-Ubuntu SMP Wed Dec 1 23:51:13 UTC 2010 >> i686 GNU/Linux >> >> ipython 0.10-1 >> python 2.6.4-0ubuntu1 >> python-matplotlib 0.99.0-1ubuntu1 >> python-numpy 1:1.3.0-3 >> python-tk 2.6.3-0ubuntu1 >> >> >> I have included a listing showing all versions of all packages with names >> containing the string "python", on both machines. [*Not* posted to the >> list.] >> Best, Paul >> >> > Trying out the script on another machine of mine, I was able to reproduce > the problem. I will have to see what is the difference between my two > computers that would cause the other one to work perfectly fine. > > Ben Root > > Paul, I have not figured out what is causing the difference between my computers. This might be backend-dependent (and maybe version-dependent). Have you tested your code on different backends? Ben Root ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Benjamin Root - 2011-02-16 00:47:10 Attachments: Message as HTML ```On Tue, Feb 15, 2011 at 6:29 PM, Paul Leopardi wrote: > Hi Benjamin, > On Wed, 16 Feb 2011 03:07:25 AM you wrote: > > I have not figured out what is causing the difference between my > computers. > > This might be backend-dependent (and maybe version-dependent). Have you > > tested your code on different backends? > > I don't know what you mean by different backends. What are the possible > ones, > and how do you configure them? Where is this documented? > Best, Paul > http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend Personally, I use the second approach with "matplotlib.use('GTKAgg')" or whatnot. Based on what I saw you listed as available packages, you should have TkAgg and WxAgg available. Ben Root ```
 Re: [Matplotlib-users] Multiple mplot3d figures: new plots display over old ones? From: Paul Leopardi - 2011-02-25 10:14:48 ```Hi Benjamin, > > On Wed, 16 Feb 2011 03:07:25 AM you wrote: > > > I have not figured out what is causing the difference between my > > > computers. > > > This might be backend-dependent (and maybe version-dependent). Have > > > you tested your code on different backends? Sorry for my delay in replying. I have had a busy week. I've now tested my PC running OpenSUSE 11.2 with python-matplotlib-1.0.1-20.1.x86_64. I ran ipython -pylab with various values for "backend=" in the matplotlibrc file. The results for all listed backends follow. Best, Paul # No figures are displayed: Agg,Cairo,GDK,PS,PDF,SVG,Template # Bug: Last plot is displayed in all figures: GTK,GTKAgg,GTKCairo,TkAgg,WXAgg # Two Bugs: Figures remain blank until last plot completed. # Last plot is displayed in all figures. Qt4Agg # Failed with error message: CocoaAgg # The CococaAgg backend required PyObjC to be installed! # (currently testing v1.3.7) FltkAgg #ImportError: No module named fltk MacOSX #ImportError: cannot import name _macosx QtAgg # RuntimeError: the sip module implements API v8.0 to v8.1 but the qt module requires API v7.1 WX # NotImplementedError: wx.GraphicsContext is not available on this platform. ```