主程序:return_plot_example(200)
function return_plot_example(M)
% copyright by fantuanxiaot
% M是收益率的个数
% 离散回报率的作图
% 回报率基于正态分布生成
%% 样本收益率线状图
Return=normrnd(0,0.01,M,1);
figure(1)
set(figure(1),'color','w')
subplot(1,2,1)
hold on
plot(Return,'go','markeredgecolor','k','markerfacecolor','g','markersize',8)
plot(Return,'b','linewidth',1)
title('样本收益率线状图','fontname','楷体','fontsize',16)
legend('收益率','收益率')
%% 样本收益率的杆状图
subplot(1,2,2)
h=stem(Return);
set(h,'color','b')
set(h,'MarkerFaceColor','m','MarkerEdgeColor','k','markersize',8)
legend('收益率')
title('样本收益率杆状图','fontname','楷体','fontsize',16)
hold off
print(gcf,'-dpng','return_plot_example.png');
end