Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I put a title on the colorbar in matlab output?

Tags:

matlab

The output of my program is an area plot and there is a title of the figure But I want to put a title on the colorbar also. i have searched many functions but I am not able to do this. can anyone help me ??

like image 554
Prateek Verma Avatar asked Dec 12 '12 13:12

Prateek Verma


People also ask

How do you add a title to a figure in Matlab?

Create Title and SubtitleCreate a plot. Then create a title and a subtitle by calling the title function with two character vectors as arguments. Use the 'Color' name-value pair argument to customize the color for both lines of text. Specify two return arguments to store the text objects for the title and subtitle.

How do I plot a color bar in Matlab?

colorbar( target ,___) adds a colorbar to the axes or chart specified by target . Specify the target axes or chart as the first argument in any of the previous syntaxes. c = colorbar(___) returns the ColorBar object. You can use this object to set properties after creating the colorbar.


2 Answers

This is relatively easy to do using the handle output from colorbar:

imagesc(randn(10));
h = colorbar;
title(h,'my colorbar')
like image 158
Pete Avatar answered Sep 26 '22 08:09

Pete


In addition to Pete's excellent answer, if you want a label on the side of the colorbar use this:

[X,Y,Z] = peaks;
figure;
contourf(X,Y,Z,20);
h = colorbar;
ylabel(h,'Side colorbar label');
like image 27
OSE Avatar answered Sep 26 '22 08:09

OSE