MATLAB Answers

Disable font smoothing in colorbar object

11 views (last 30 days)
Vicky
Vicky on 28 Sep 2020 at 20:54
Commented: Vicky on 28 Sep 2020 at 23:32
Hi everyone,
I am trying to produce a figure with the FontSmoothing property disabled throughout. The figure has one axes object with a title, two axis labels, two plot()'ted lines, a legend, and a colorbar. My problem is that I can't find a way to turn off font smoothing for the colorbar tick labels. The colorbar object does have a Label property which in turn has a FontSmoothing property, but turning that off only affects the colorbar label (as the name would suggest). The tick labels remain unaffected.
I have read other answers showing how to turn off font smoothing for legend objects (basically, you have to use the 4-output-argument form of legend()), but I could not find a way to do something similar for colorbar().
This is what I have been able to accomplish so far: (I am using MATLAB R2019a for Linux)
The colorbar tick labels remain font-smoothed.
The colorbar tick labels ( -16.5 through -19.5 ) clearly have some sort font smoothing (font antialiasing) enabled. How can I disable that?

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Sep 2020 at 21:36
cb = colorbar(appropriate_axes);
cb.Ruler.FontSmoothing = 'off';

  3 Comments

Vicky
Vicky on 28 Sep 2020 at 22:48
Thank you so much! This is perfect!
As a side question, why does the Ruler entry seem to be hidden from the user? When I enumerate the properties of the colorbar with:
k=findall(gcf(),'Type','colorbar');
get(k(1))
the Ruler entry is not listed. The documentation does not mention at all that this property exists for colorbars, either (R2019a Function Reference p.1/1729--1/1766; Graphics Guide p.10/2--10/9).
Walter Roberson
Walter Roberson on 28 Sep 2020 at 22:53
As a side question, why does the Ruler entry seem to be hidden from the user
I do not know; the decisions of Mathworks about what to expose and what not to expose are a mystery to me.
orderfields(struct(k(1))) %you will probably get a warning about the struct()
Vicky
Vicky on 28 Sep 2020 at 23:32
Your messages were really enlightening, thanks a lot!

Sign in to comment.

More Answers (1)

sushanth govinahallisathyanarayana
sushanth govinahallisathyanarayana on 28 Sep 2020 at 21:24
You can use gca to get a handle to the current axes, after that you can use the properties of the axes to set accordingly.

  1 Comment

Walter Roberson
Walter Roberson on 28 Sep 2020 at 21:36
No, the axes settings do not control the settings of the colorbar label.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!