Adding a colorbar to a figure

16 vues (au cours des 30 derniers jours)
Yow-Ren Chang
Yow-Ren Chang le 16 Sep 2017
Commenté : Yow-Ren Chang le 18 Sep 2017
Hi, I am trying to display a colorbar in a figure. So some background on what I am doing: I am tracking objects (from images) in 3D and in time. I wanted to just visualize the tracking so I am plotting the x and y position of an object as a circle and then color-code the circle to represent z. The way I color code is I check at what z position an object is and then assign it a color (see below).
The code is something like this:
figure;
% display the original image
imshow(image)
hold on
% loop through the data and check z position to color-code
for j = 1:n
viscircles(data(j,1:2,radius(j),'color',colors(round(data(j,3)),:));
end
where the columns in 'data' are the x, y, z positions and 'colors' is a colormap that I defined for certain z values. So I get an image something like the one attached.
So I was wondering if anyone could point me in a direction for how to add a colorbar in the figure to provide information about the z position? Any help would be greatly appreciated, thanks!

Réponse acceptée

Image Analyst
Image Analyst le 16 Sep 2017
Use the colorbar(), colormap(), and caxis() functions.
  1 commentaire
Yow-Ren Chang
Yow-Ren Chang le 18 Sep 2017
Thanks, creating two axes and then specifying which axis for the colorbar did the trick.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by