Can the Font Size of an Axis Label be Reliably Determined Programatically
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
AFAICT, there are three ways to set the font size of an axis label and there are three ways to get the font size of an axis lable. However, the three ways to get the font size of the axis label can return different answers and seem to depend on how the font size of the axis label was set in the first place. As will be shown, they are even inconsistent if the user takes no action to change the font size of the axis lablel from the default. Here is the code that demonstrates:
figure(10)
plot(rand(6))
xlabel('XLABEL')
[get(gca,'FontSize')*get(gca,'LabelFontSizeMultiplier') get(get(gca,'XAxis'),'FontSize') get(get(get(gca,'XAxis'),'Label'),'FontSize')]
figure(1)
plot(rand(6))
xlabel('XLABEL')
set(gca,'LabelFontSizeMultiplier',1.5)
[get(gca,'FontSize')*get(gca,'LabelFontSizeMultiplier') get(get(gca,'XAxis'),'FontSize') get(get(get(gca,'XAxis'),'Label'),'FontSize')]
figure(2)
plot(rand(6))
xlabel('XLABEL')
set(get(gca,'XAxis'),'FontSize',15)
[get(gca,'FontSize')*get(gca,'LabelFontSizeMultiplier') get(get(gca,'XAxis'),'FontSize') get(get(get(gca,'XAxis'),'Label'),'FontSize')]
figure(3)
plot(rand(6))
xlabel('XLABEL')
set(get(get(gca,'XAxis'),'Label'),'FontSize',15)
[get(gca,'FontSize')*get(gca,'LabelFontSizeMultiplier') get(get(gca,'XAxis'),'FontSize') get(get(get(gca,'XAxis'),'Label'),'FontSize')]
ans =
11 10 11
ans =
15 10 11
ans =
11 15 11
ans =
11 10 15
Interestingly enough, the middle result in the first answer is incorrect (I think?), even before actively changing the label fontsize.
It certainly looks like that there is NO WAY to reliably, programmatically determine the font size of the label w/o knowing how it was set in the first place. Depending on how the label font size was set, and depending on which one of the three interrogation methods are used, one might or might not get the correct answer. This is very troubling, is it not? Especially for those who have to work with figures for which the code that generated the figure is not available.
I actually ran into this issue some time ago and don't recall all of the details of what I saw in the doc. However, I do recall that each individual methods for setting and getting the fontsize could be found, but there was no discussion of how they influence each other, at least not that I could find.
0 commentaires
Réponses (1)
Sourabh Kondapaka
le 17 Sep 2020
Hi,
I have brought this issue to the notice of our developers. They will investigate the matter further.
4 commentaires
Sourabh Kondapaka
le 21 Sep 2020
The inconsistency in values is because they are updated at the end of the script. If you would like to update it immediately and see the correct values use the "draw now" command.
Please find an example below:
figure(10);
plot(rand(6))
xlabel('XLABEL');
k = gca;
k.FontSize = 19;
drawnow
disp(get(get(gca,'XAxis'),'FontSize'));
get(get(get(gca,'XAxis'),'Label'),'FontSize')
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!