MATLAB: 2D plot transformation help

2dplot

How do I transform the top picture to the bottom one? Here is the code to plot bottom picture.
n1=[1:60];
n2=[1:60]+60;
n3=[1:60]+120;
N=180;
y1=sqrt(2/N)*cos(pi*10.*(n1-0.5)/N);
y2=sqrt(2/N)*cos(pi*20.*(n2-0.5)/N);
y3=sqrt(2/N)*cos(pi*30.*(n2-0.5)/N);
y2=sqrt(2/N)*cos(pi*60.*(n2-0.5)/N);
y = [y1 y2 y3];
n = [n1 n2 n3];
plot(n, y)

Best Answer

The top figure is a combination of a slightly modified stem plot and a line plot:
figure(1)
stem(n, y, 'Marker','none')
hold on
plot(xlim, [0; 0], '-r', 'LineWidth',1)
hold off
The stem plot normally puts markers at the ends of the stems, so it is necessary to switch those off. The red x-axis is a line plot. Experiment with the plot to get the result you want.