matlab - Set color of specific values with colormap -


so small version of trying accomplish have matrix a;

a = [0 1 0; 2 0 0;1 3 6;9 0 1]; imagesc(a) 

so when use imagesc(a) nice grid each value represented different color. want able set value of 0 white , ideally able change other colors see fit such if know 2 values represent same thing 3 , 6, set same or relatively similar colors. imagesc wrong command use because can tell uses color gradient.

thanks

2 options:

  1. you can create own colormap shown in how create custom colormap programmatically?
  2. or map matrix a matrix coloured want it. if know want 3 , 6 same colour create mapping function makes so. use a index map 3rd , 6th element of map must same e.g.

    map = [1, 2, 3, 4, 5, 6, 4, 7, 8, 9, 10]; imagesc(map(a+1)) 

    note elements 4 , 7 in map same because a values start 0, why there +1 in second line.

    and choose colormap starts white.

personally go method 1.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -