How to turn off text interpreter when plotting timeseries objects

72 ビュー (過去 30 日間)
Bill Tubbs
Bill Tubbs 2020 年 10 月 25 日
編集済み: Stephen23 2020 年 10 月 25 日
I am plotting timeseries objects using plot.
My variable names include underscores (e.g. 'ABC_DEF') and I do not want these interpreted as LATEX (no subscripts).
It works fine on a single plot:
ts = timeseries((1:10)',randn(10,1),'Name','ABC_DEF');
figure
plot(ts)
But when you do subplots the interpreter seems to be set to LaTex:
figure
subplot(2,1,1); plot(ts)
subplot(2,1,2); ts.plot()
This answer explains how to change the interpreter for individual text commands but I can't find anything on this for timeseries plots.

採用された回答

Stephen23
Stephen23 2020 年 10 月 25 日
編集済み: Stephen23 2020 年 10 月 25 日
One approach would be to set the interpreter for the entire figure before plotting (and reset it again afterwards):
For example:
fgh = figure(..);
set(fgh,'defaultTextInterpreter','none')
... create axes and plot data
Depending on the version you are using you might also want to set the axes' TickLabelInterpreter as well.

その他の回答 (1 件)

VBBV
VBBV 2020 年 10 月 25 日
編集済み: VBBV 2020 年 10 月 25 日
Use a space and backslash between ABC _ DEF when interpreting variables.
Latex treats text after _ subscript
ts = timeseries((1:10)',randn(10,1),'Name','ABC\_DEF');
figure
plot(ts)
figure
subplot(2,1,1); plot(ts)
subplot(2,1,2); ts.plot()
  1 件のコメント
Bill Tubbs
Bill Tubbs 2020 年 10 月 25 日
編集済み: Bill Tubbs 2020 年 10 月 25 日
Thanks. This works but means that ts.Name is now not as readable. It also means that the name is now displayed incorrectly in the single plot.
I'd prefer to turn off the interpreter during plotting if there is a way to do that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by