0

For the following matlab code:

figure;imshow( imread('cameraman.tif') ,[])
hold on;scatter(1:200,1:200,[],1:200);colorbar

As we can see, the color of scatter is gray because the colorbar of 'cameraman.tif' is gray. What if I want the colorbar of scatter is jet or hsv? I search some information from network, and I find that one axes has just one colorbar.

So, my question is that how to set the colorbar of scatter to jet and remain the colorbar of 'cameraman.tif' to be gray?

ZhQ

Erfan
  • 1,897
  • 13
  • 23
Qiang Zhang
  • 820
  • 8
  • 32
  • Have a look [here](http://stackoverflow.com/a/39741044/2627163) and [here](http://stackoverflow.com/a/38233971/2627163) – EBH Oct 07 '16 at 08:04
  • (1) There is only one colormap per `figure` not `axes`. (2) In your code the scatter cannot be seen at all. (3) Do you want to show both axes with 2 different colorbars? – EBH Oct 07 '16 at 08:11

2 Answers2

1

The problem appears in your scatter. Take a look at here to see how you can define colors for scatter. I modified your code to:

figure;
imshow(imread('cameraman.tif'),[])
hold on
scatter(1:200,1:200,[],jet(200)) % this is what I changed
colorbar

and now it looks fine:

enter image description here

Erfan
  • 1,897
  • 13
  • 23
  • What if I want to assign the intensity of scatter points to 1:200? And I want the colorbar represent the color map of scatter points rather than the image. What can I do? – Qiang Zhang Oct 07 '16 at 08:53
  • then you form your `jetmat = jet(200);` so you can use your scale like `jetmat((1:200),:)`. The scatter points do not have *colormap*. There is no straightforward way to do so. – Erfan Oct 07 '16 at 09:06
1

I have find another solution for this problem: enter link description here

Qiang Zhang
  • 820
  • 8
  • 32