使绘图和图像中的颜色相同

时间:2014-11-20 23:43:18

标签: matlab

我在MATLAB中设计了一个可视化模拟,如下所示:

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')

1 个答案:

答案 0 :(得分:3)

很难说明您希望如何排序颜色,但这会将colormap从默认值更改为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')

enter image description here

相关问题