The default interpreter for the 'title' command is 'tex'. How can the default be changed to 'latex'?

125 次查看(过去 30 天)
There are factory settings for other interpreters, that can be accessed by typing
get(root,'factory')
I have written a script to change all the 'interpreters' to 'latex', my preference. However, I do not see a factory setting for the
title
command. I wish to avoid having to type
title('\(\varepsilon\)','interpreter','latex')
every time. Can someone help? Thank you.

采纳的回答

Walter Roberson
Walter Roberson 2018-4-21
ax = gca;
ax.Title.String = '';
ax.Title.Interpreter = 'latex';
set(groot,'DefaultAxesTitle', ax.Title);

This is a complete title() object that gets set.

Each time you create a new axes, it will set the axes Title object to the object that was created. This will set the Parent of the Title object to be the appropriate axes, which will stop it from displaying where it was and start displaying it in the new axes. Any change in the new axes (such as to the string) will affect the properties for all of the other axes it is set to, because all of those axes will have handles to the same Title object. delete() of any one of the references will delete it for all of the references.

You will probably find this highly unsatisfactory... but you asked ;-)

There does not appear to be any way to set just the Interpreter property by the groot/default mechanism. This is unfortunate.

更多回答(1 个)

Steven Lord
Steven Lord 2020-8-25
There is no way to change the default Interpreter just for axes titles. Axes titles are not their own type of object, they are text objects. Because of that you could change the default properties for all text objects in the figure and that would affect the axes titles, but it would also affect all text objects in the figure. This includes the title, axes labels, and explicitly created text objects.
f = figure;
set(f, 'DefaultTextColor', 'r')
plot(1:10)
title('Sample title');
xlabel('Sample xlabel');
text(3, 7, 'abracadabra');
If you want to control the properties just of all axes titles, you could write your own wrapper function around title that sets your desired properties.
function t = mytitle(varargin)
t = title(varargin{:});
t.Color = 'r';
end
Now a slight modification of the example above:
f = figure;
plot(1:10)
mytitle('Sample title');
xlabel('Sample xlabel');
text(3, 7, 'abracadabra');
The title is red, but the axes label and the text object are not.

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by