필터 지우기
필터 지우기

Test Disappear from Chart

조회 수: 3 (최근 30일)
Yousif Alaraji
Yousif Alaraji 2023년 10월 31일
댓글: Voss 2023년 11월 2일
Hello everyone
Kindly I am facing an Issue with Matlab trying to print a Chart but that one when I write a text in Xlabel as a one line it works fine but if I add new line it Disappear
As you can see in this chart its one line but this line is long so I need to add new line and when I add new Line one of these text diappear as in below
You can see when I added new Line the Text on the left diapeared
I am using this for the one line:
x_labels{cat_indices(max_accuracy_index)} = [cat, ' - Method: ', method{cat_indices(max_accuracy_index)}, ' Accuracy: ', num2str(max_accuracy), ' Time: ', num2str(time_period(cat_indices(max_accuracy_index)))];
when I added new line I used this:
x_labels{cat_indices(max_accuracy_index)} = sprintf('%s - Method: %s\nAccuracy: %.2f Time: %.2f', cat, method{cat_indices(max_accuracy_index)}, max_accuracy, time_period(cat_indices(max_accuracy_index)));
This causing one text disapearing, I tried to change the Figure size but it doesn't work
figure('Position', [100, 100, 1000, 600]);
and I even change it to
figure('Position', [100, 100, 2000, 600]);
but still no change
I hope if someone experienced such thing could help me

답변 (1개)

Voss
Voss 2023년 10월 31일
Try using '\\newline' instead of '\n' in sprintf:
cat = 'Final Bump Road Obstacle';
method = {'WaveletScattering and SVM Tuned RFE'};
cat_indices = 1;
max_accuracy_index = 1;
max_accuracy = 100;
time_period = 70;
x_labels{cat_indices(max_accuracy_index)} = sprintf('%s - Method: %s\\newlineAccuracy: %.2f Time: %.2f', cat, method{cat_indices(max_accuracy_index)}, max_accuracy, time_period(cat_indices(max_accuracy_index)));
x_labels = 1×1 cell array
{'Final Bump Road Obstacle - Method: WaveletScattering and SVM Tuned RFE\newlineAccuracy: 100.00 Time: 70.00'}
figure('Position',[10 10 1000 500])
plot(1:10)
xticks(1:2:10)
xticklabels(x_labels(ones(1,numel(xticks())))) % repeating the same label 5 times
  댓글 수: 6
Yousif Alaraji
Yousif Alaraji 2023년 11월 2일
Yes dear this is working now
Thank you so much
Voss
Voss 2023년 11월 2일
You're welcome! Any questions, let me know. Otherwise, please "Accept" this answer. Thanks!

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by