2

I want a plot as the following:

Wigner plot

Here, the Wigner function calculated from the x,y data is plotted as W and its projection on the x-y plane is also shown. I have used the following code that plots the Wigner function. How to show the projection of W on the x-y plane in the same plot?

xvec = [-2:2]; 
yvec = xvec;
W = wfunc(psi,xvec,yvec,g);
f1 = figure(1); 
mesh(xvec,yvec,real(W));
shading interp
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58

1 Answers1

2

You can use hold on to add many graphical objects in the same figure. For example:

figure    
surf(xvec,yvec,real(W),'linestyle','none')
hold on
contourf(xvec,yvec,real(W),100,'linestyle','none')

You can shift the z-position of the contour colormap (following to the comment here) using

[~,hc] = contourf(xvec,yvec,real(W),100,'linestyle','none');
hcpatches = findobj(hc,'Type','Patch');
for n=1:length(hcpatches)
  set(hcpatches(n),'ZData',-5*ones(size(get(hcpatches(n),'XData'))))
end

Also, you can try to use surfc.

Community
  • 1
  • 1
Alexander Korovin
  • 1,639
  • 1
  • 12
  • 19