How to fix the superscript in the ticklabels of my boxplot?

21 ビュー (過去 30 日間)
Lea
Lea 2016 年 12 月 18 日
コメント済み: Andrew Winter 2019 年 1 月 17 日
Hi, I am generating the attached plot using the code below. I cannot get 'xticklabel' to display the superscript in the label units correctly: instead of making the superscript, it prints m^{-3} on the plot. I assume this has something to do with having curly brackets within another set of curly brackets in the set...xticklabel command but I have not been able to find a workaround. Can someone help?
ff=figure('name', 'box');
boxplot(X,groups1, 'positions', positions, 'color',CM, 'symbol', '+');
l=legend(findobj(gca,'Tag','Box'), ll);
set(gca,'xtick',length(fileList)/2: length(positions)/3: length(positions)-1.5)
set(gca,'xticklabel',{'density [kgx10 m^{-3} ]', 'Tw [°C]', 'Wind [m s^{-1}]'})
set(gca, 'Fontsize', 14, 'Fontweight', 'bold');
pos = get(ff,'position');
set(ff,'position',[pos(1:2)/4 pos(3:4)*2]);
title('Comparison of stations')
grid on

採用された回答

Mischa Kim
Mischa Kim 2016 年 12 月 18 日
Lea, this might help. Add
set(gca,'TickLabelInterpreter', 'tex');
before setting the xticklabel.
  2 件のコメント
Lea
Lea 2016 年 12 月 18 日
Thank you for your quick reply (on a sunday no less!) This worked. So simple but it didn't occur to me because it was previously working without setting the interpreter in other plots.
Andrew Winter
Andrew Winter 2019 年 1 月 17 日
Thanks for your reply! It saved me so much time.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by