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()

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to