2014-11-20 38 views
2

我設計我在MATLAB仿真的可視化,看起來像這樣:使色彩的情節和於imagesc相同

simulation

如何讓這個plotimagesc使用相同的顏色嗎?我希望能夠看到情節中的傳說,並將該行與左側可視化中的相同顏色進行比較。

MWE:

field=randi(7,10); 
distribution=rand(100,7); 

h=figure(1); 
set(gcf,'PaperPositionMode','auto') 
set(h, 'Position', [500 500 1000 500]) 
subplot(1,2,1); 
imagesc(field); 
colormap('copper'); 
subplot(1,2,2); 
plot(distribution); 
legend('1','2','3','4','5','6','7') 

回答

3

很難告訴你如何想的顏色來進行排序,但是這會更改默認的colormapcopper

%// sample data 
field=randi(7,10); 
distribution=rand(100,7); 

h=figure(1); 
set(gcf,'PaperPositionMode','auto') 
set(h, 'Position', [500 500 1000 500]) 

subplot(1,2,1); 
imagesc(field); 
colormap('copper'); 
colorbar 
h=subplot(1,2,2); 
set(get(h,'Parent'),'DefaultAxesColorOrder',copper(7)) %// set the ColorOrder for this plot 

plot(distribution); 
legend('1','2','3','4','5','6','7') 

enter image description here

+0

你好,感謝您。由於某種原因,這不適合我。你能看看我在我的問題中附加的代碼嗎? – 2014-11-21 00:24:57

+0

我的典型運氣!它不起作用,因爲在線顏色使用默認的着色方案:/ – 2014-11-21 00:28:59

+0

對不起,我的意思是它使用默認的*顏色順序*,即它看起來就像以前一樣。這就是MWE尋找我的方式:[link](http://i.stack.imgur.com/hAdfa.png)。 – 2014-11-21 00:33:05