Reputation: 10607
I have devised a visualization of my simulation in MATLAB which looks like this:
How do I make it so that plot
and imagesc
use the same colors? I want to be able to look at the legends in the plot and compare that line with the same color in the visualization to the left.
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')
Upvotes: 2
Views: 63
Reputation: 8459
It's hard to tell how you want the colours to be ordered, but this will change the colormap
from the default to copper
.
%// 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')
Upvotes: 3