Writing x values with subscript in the graph

Dear all,
I want to writing x values with subscript in the graph as follows:
Here is my code:
data=xlsread('boxplot');
col_header={'GA_{343}','GA351','GA352','GA342','GA153','GA353','GA141','GA273','GA143','GA373'};
data=data';
boxplot(data,col_header)
xlabel('Algorithm')
ylabel('Fitness Value')
How can I do this. Also, I use MATLAB 2020a version.
Thanks.

 採用された回答

dpb
dpb 2021 年 3 月 27 日

0 投票

hAx=gca; % save the axes handle -- may want later
hAx.TickLabelInterpreter='tex'; % set tick label interpreter
Then your first column label will show the subscript; the answer for the rest is then apparent...
See the section on 'interpreter' optional named parameter at
doc text
for the details of TeX interpreter syntax.

6 件のコメント

Abdullah Türk
Abdullah Türk 2021 年 3 月 27 日
Firstly, thank you for your answer but I did not understand exactly what to do.
dpb
dpb 2021 年 3 月 27 日
Set the axis 'TickLabelInterpreter' property to 'tex'
Follow the above code as is written
Abdullah Türk
Abdullah Türk 2021 年 3 月 27 日
I write the code as follows:
col_header={'GA_3_4_3','GA_3_5_1','GA_3_5_2','GA_3_4_2','GA_1_5_3','GA_3_5_3','GA_1_4_1','GA_2_7_3','GA_1_4_3','GA_3_7_3'};
and I followed the code steps you suggested and result :
Thank you so much my friend :)
dpb
dpb 2021 年 3 月 27 日
Your original of
col_header={'GA_{343}','GA351',...
with the underscore for the first works and is easier to both write and read... :)
Abdullah Türk
Abdullah Türk 2021 年 3 月 28 日
I tried this
col_header={'GA_{343}','GA_{351}','GA_{352}','GA_{342}','GA_{153}','GA_{353}','GA_{141}','GA_{273}','GA_{143}','GA_{373}'};
and it works. Thank you so much again my friend :)
dpb
dpb 2021 年 3 月 28 日
Told ya'! :)
Glad to help; as noted earlier, the syntax rules for TeX are documented under text for future reference when want to get fancy again... :) Otherwise, it's kinda' hard to find in the doc if don't know/remember that.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

質問済み:

2021 年 3 月 27 日

コメント済み:

dpb
2021 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by