필터 지우기
필터 지우기

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.

  댓글 수: 2
Fred
Fred 2018년 4월 22일
I will sadly accept your answer, with the hope that the powers that be will consider a better solution in the future.
Fabrizio Schiano
Fabrizio Schiano 2020년 8월 25일
편집: Fabrizio Schiano 2020년 8월 25일
Is this still the case? I would like to set one interpreter for all the titles in my matlab plots.

댓글을 달려면 로그인하십시오.

추가 답변 (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