2016-01-13 53 views
0

我試圖繪製兩個數字相鄰。這個想法是在x軸上創建1到10的平方圖。我知道這個副作用函數,但是有些它不適合我。非常感謝幫助。繪製兩個彼此相鄰的Matlab數字

% plotting the data 
data1_plot=data1.*100; 
data2_plot=data2.*100; 
figure(1), 
subplot(1,2,1); 
plot((1:10)',mean(data1_plot),'o-','LineWidth',1);hold on 
for ii=2:10; 
    if mean(data1_plot(:,ii))<mean(data1_plot(:,ii-1)); 
     plot([ii-1,ii],mean(data1_plot(:,ii-1:ii)),'r.-'); 
    end 
end 
set(gca,'XTickLabel',{'Unprofitable';'2';'3';'4';'5';'6';'7';'8';'9';'Profitable'}); 
axis([0.8,10.2,0.0,1.5]),... 
    ylabel('Average return'),... 
    title('\rm Equally-weighted PMU portfolio returns, 1990-2015');hold off; 
subplot(1,2,2); 
plot((1:10)',mean(data2_plot),'o-','LineWidth',1);hold on 
for ii=2:10; 
    if mean(data2_plot(:,ii))<mean(data2_plot(:,ii-1)); 
     plot([ii-1,ii],mean(data2_plot(:,ii-1:ii)),'r.-'); 
    end 
end 
set(gca,'XTickLabel',{'Weak';'2';'3';'4';'5';'6';'7';'8';'9';'Robust'}); 
axis([0.8,10.2,0.0,1.5]),... 
    ylabel('Average return'),... 
    title('\rm Equally-weighted RMW returns, 1990-2015');hold off; 

plots

+0

你的陰謀鏈接看起來(從格式錯誤分開)沒關係你怎麼想你的陰謀是什麼樣子?你的描述很模糊。 – GameOfThrows

+0

劇情鏈接是輸出。問題是,當我把下襬分成兩個單獨的區域時,我得到兩個非常整齊的方塊形狀。但是,當我將圖與子圖函數結合時,我會得到鏈接中給出的輸出。我希望在不調整尺寸的情況下合併這兩個地塊 – Tim

回答

3

可以使用

axis square 
xlim([1 10]) 

第一個命令使當前的軸區域的正方形(web)和所述第二組中的x軸的限制。

例子:

subplot(1,2,1) 
plot(1:10); 
axis square 
xlim([0 12]); 

subplot(1,2,2) 
plot(1:10); 
axis square 
xlim([1 10]); 

enter image description here