将Matlab颜色绘制为垂直条 [英] Plot Matlab colours as vertical bars

查看:247
本文介绍了将Matlab颜色绘制为垂直条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶然发现这

解决方案

一个相当简单的方法如下:

  a = [0 0 1.0000; 
1.0000 0 0;
0 1.0000 0;
0 0 0.1724;
1.0000 0.1034 0.7241;
1.0000 0.8276 0;
0 0.3448 0]

figure
imagesc(1:size(a,1));
colormap(a);
%可选,但整理了一点
set(gca,'clim',[0.5(size(a,1)+ 0.5)]);

%也是可选的,删除轴上的标记
set(gca,'xtick',[],'ytick',[]);

输出:




I stumbled upon this file exchange submission, which, given a positive integer, generates that many "maximally distinguishable" colours. The tool is working great, but I would like to visualize the colours it generates with coloured vertical bands. An example, taken from the linked blog article:

For the choice of colours:

ans =
         0         0    1.0000
    1.0000         0         0
         0    1.0000         0
         0         0    0.1724
    1.0000    0.1034    0.7241
    1.0000    0.8276         0
         0    0.3448         0

We obtain the vertical bands on the left that show these colours.

解决方案

A fairly simple way would be as follows:

a = [     0         0    1.0000 ;
     1.0000         0         0 ;
          0    1.0000         0 ;
          0         0    0.1724 ;
     1.0000    0.1034    0.7241 ;
     1.0000    0.8276         0 ;
          0    0.3448         0 ]

figure
imagesc(1:size(a, 1));
colormap(a);
% Optional, but neatens things up a bit
set(gca, 'clim', [0.5 (size(a, 1) + 0.5)]);

% Also optional, removes the ticks from the axes
set(gca, 'xtick', [], 'ytick', []);

output:

这篇关于将Matlab颜色绘制为垂直条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆