Azzera filtri
Azzera filtri

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

125 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 21 Apr 2018
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 Commenti
Fred
Fred il 22 Apr 2018
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 il 25 Ago 2020
Modificato: Fabrizio Schiano il 25 Ago 2020
Is this still the case? I would like to set one interpreter for all the titles in my matlab plots.

Accedi per commentare.

Più risposte (1)

Steven Lord
Steven Lord il 25 Ago 2020
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.

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by