MATLAB Answers


How to display colorbar label with App Designer

Asked by Marco Furlan on 5 Jul 2019
Latest activity Commented on by Marco Furlan on 1 Aug 2019
I'm trying to display the colorbar label in an axis from App Designer but the text goes outside the limits and is not properly displayed as shown below:
The code I'm usig:
c = colorbar(app.UIAxes)
colormap(app.UIAxes, jet)
c.Label.String = 'Example Color Label';
How can I properly display the label?


Sign in to comment.

1 Answer

Answer by Yogesh Khurana on 18 Jul 2019
 Accepted Answer

You can try editing axes font size to a value less than the default value that is 12. If you change the axes font size, then MATLAB automatically sets the font size of the colorbar to 90% of the axes font size. I have written the following code to change axes font size:
c = colorbar(app.UIAxes);
colormap(app.UIAxes, jet);
c.Label.String = 'Example Color Label';
app.UIAxes.FontSize = 10;
The output of above code is:
Another way is to set the position of colorbar manually using Position property of colorbar.
You can also refer to documentations of Axes properties and Colorbar properties:
Colorbar Properties:

  1 Comment

Sign in to comment.