Change color of numbers at colorbar

26 views (last 30 days)
Tim Dwertmann
Tim Dwertmann on 16 Jun 2021
Edited: dpb on 17 Jun 2021
Hey, is there a way to change the color of the written numbers at the colorbar? I don´t want to chance the colormap, just the color of the numbers at the color axis.

Accepted Answer

dpb
dpb on 16 Jun 2021
Undocumented property -- underneath is a NumericRuler object which does control the axes ticklabels independently.
figure
surf(rand(5))
colormap(turbo)
hcb = colorbar;
hcb.Ruler.Color='b';
yields
And, you can set
hcb.Color='r';
afterwards and not destroy the label colors but change the box outline only.
I've railed over and over about the penchant for hiding properties that TMW seems to get more and more enamored with...
  5 Comments
dpb
dpb on 17 Jun 2021
Edited: dpb on 17 Jun 2021
I HAD tried this before I made the comment... :)
That there isn't a FontColor to go along with rest of font properties is the oversight -- not only here, but fairly globally.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 16 Jun 2021
surf(rand(5))
colormap(turbo)
hcb = colorbar;
hcb.Ruler.TickLabelFormat = '\\color{red}%g';
The double \\ is important for this purpose.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!