필터 지우기
필터 지우기

Greek letters and label alignment in boxplot graph

조회 수: 4 (최근 30일)
Christian
Christian 2015년 11월 25일
편집: Christian 2015년 11월 25일
Hello,
in three slightly different models I have calculated the results for the same 5 sets of parameter combinations and would like to display the results in a boxplot graph. This works so far well but the tick-labeling of the x-axis does not look nice for two reasons:
1) I cannot get the labels to show the real greek symbols
2) It would probably look nicer if the parameter set label (Base Case, etc.) would either be centered under the three respective graphs or at least left aligned with "M1"
Would be very thankful for any hints or advice!
Best regards
Christian
Here is the code as well as the graph it produces:
% Output of models: first column are results for 10.000 simulations of first parameter set,
% second column results of 10000 simulations of second parameter set, etc.
Model_1 = rand(10000,5);
Model_2 = rand(10000,5);
Model_3 = rand(10000,5);
DataforBoxplot = cat(2,Model_1, Model_2, Model_3); % Combine model data in one matrix
figure('units','normalized','outerposition',[0 0 1 1])
Parameterset = repmat({'Base Case' 'Case \alpha' 'Case \beta' 'Case r' 'Case \gamma'},1,3);
Modellabel = [ repmat({'M1'},1,5) , repmat({'M2'},1,5) , repmat({'M3'},1,5) ];
boxplot(DataforBoxplot, {Parameterset, Modellabel}, 'factorgap', [10 0], 'labelverbosity', 'minor')
title('Example graph')
ylabel('Model output')
xlabel('Model (1-3) and parameter set used')

채택된 답변

Thorsten
Thorsten 2015년 11월 25일
To get Greek letters
Parameterset = repmat({'Base Case' ['Case ' char(945)] ['Case ' char(946)] 'Case r' ['Case ' char(947)]},1,3)
  댓글 수: 6
Christian
Christian 2015년 11월 25일
편집: Christian 2015년 11월 25일
Thanks a lot!
However with the Greek letters and the subscripts in the tick labels I get problems when exporting the figure. For the figure to fit into the overall journal text, I have to edit font and font size of all text within the figure. That works fine as long as I look at the figure only within Matlab. Exporting to pdf or eps format however causes the problem that every string that includes a Greek letter falls back into the original Matlab font type.
Here is the code I use and a snapshot as an example:
set(0,'defaultAxesFontName', 'Times New Roman')
set(0,'defaultTextFontName', 'Times New Roman')
set(0,'defaulttextfontsize', 12)
Model_1 = rand(10000,5);
Model_2 = rand(10000,5);
Model_3 = rand(10000,5);
figure('units','normalized','outerposition',[0 0 1 1])
DataforBoxplot = cat(2,Model_1, Model_2, Model_3);
Parameterset = repmat({'Base Case' ['Case ' char(945)] ['Case ' char(946)] 'Case r' ['Case ' char(947)]},1,3);
Modellabel = [ repmat({'M1'},1,5) , repmat({'M2'},1,5) , repmat({'M3'},1,5) ];
boxplot(DataforBoxplot, {Parameterset, Modellabel}, 'factorgap', [10 0], 'labelverbosity', 'minor')
hold on
title('Example graph')
ylabel('Model output')
xlabel('Model (1-3) and parameter set used')
iptsetpref('ImshowBorder','tight');
export_fig Testfile -pdf -transparent
Any ideas how to fix this file saving problem? Thanks so much!

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

추가 답변 (0개)

카테고리

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