I have a spatial, categorical dataset that I have plotted up using pcolor. The dataset contains latitude, longitude and vegetation type data. Vegetation type is an arbitrary number between 1 and 19 that corresponds to a vegetation label.
I am looking for a way to create a colorbar "legend" for this data.
At the moment, when I use pcolor and add a colorbar, I get a bar that goes from 1 - 19 with all the different colours in between. This colorbar means nothing because the data are not ordinal.
I am hoping to find a way to make little boxes for each individual color, and put a label next to the box. Something like the maps of Australia seen on this site http://www.environment.gov.au/node/22149
Is there a way to code this in Matlab, given that I have 19 different vegetation types, and putting labels next to the colorbar would be too busy?
Thanks for your help.

 채택된 답변

Image Analyst
Image Analyst 2014년 4월 2일

0 개 추천

Have you seen the demo for colorbar where they change the labels from numbers to some custom words? Try that:
surf(peaks(30))
colorbar('YTickLabel',...
{'Freezing','Cold','Cool','Neutral',...
'Warm','Hot','Burning','Nuclear'});

댓글 수: 3

By the way, did you know pcolor() does not plot every element in your array? Try this:
pcolor(randi(255,3,3)) % Display 3 by 3 array (hopefully)
and see how many tiles get painted for this 3 by 3 array. Were you expecting a 3 by 3 array? Surprise!!! Then replace pcolor with image() or imshow().
Claire
Claire 2014년 4월 3일
Thanks for your help.
The problem with that solution is that it only works when you have a small number of categories. I have 19 in total, and when you try to label the colorbar directly, it just becomes a big mess.
I need to find another way to do this that works for a large number of labels.
Image Analyst
Image Analyst 2014년 4월 3일
If you're going to have 19 segments over a screen size, or a certain height on the paper, then the only way is to have the font size be smaller. Do you not consider your example to be a mess? Why not? Because the letters are separated? Well they are small font sizes - it's a tradeoff.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2014년 4월 2일

댓글:

2014년 4월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by