1

I want to show a gussian function which moves by time. The below code I wrote can do it for me. Now, I want to fix a 2D background in xy plane and then move this gussian function over it (superimposing a 3D plot over a 2D plot). Is there any way to do it? Thanks for any help

import math
import numpy as np
import matplotlib.pyplot as plt
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
import time

teta=45;              # direction
v=0.09                        # Speed
sigma_x=0.1;              
sigma_y=0.1;               
x_0=0;                        # Initial location (center) of gussian function
y_0=0; 
T=20

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
count=-1
for t in [i for i in range(T+1)]:
    Miu_x=x_0+v*t*cos(teta*pi/180);
    Miu_y=y_0+v*t*sin(teta*pi/180);
    L=[]
    x_1=[]
    y_1=[]
    count=count+1    
    time.sleep(0.5) 
    for x in [-4+0.1*i for i in range(80)]:
        for y in [-4+0.1*i for i in range(80)]:
            a_x=pow((x-Miu_x)/(1.4*sigma_x),2);
            a_y=pow((y-Miu_y)/(1.4*sigma_y),2);
            x_1.append(x)
            y_1.append(y)
            zz=(exp(-1*(a_x+a_y)))
            L.append(zz);
     ion()
     draw() # force a draw
     plot(x_1,y_1, L, zdir='z')
4

0 回答 0