Unexpected error when plotting a bar chart

조회 수: 2 (최근 30일)
Mingjia Hu
Mingjia Hu 2020년 7월 6일
댓글: Mingjia Hu 2020년 7월 6일
figure('Name','frequency of reduced category response by groups');
h = bar(mean_resp_bygroup([3,4,2,1],:)); %mean_resp_bygroup is a 4-by-2 double matrix
h.YLabel = 'Reduced Category Response';
h.DisplayName = {'OR','XOR'}; %legend labels
h.XTickLabels = {'W','X','Y','Z'};
legend();
title('Frequency of Reduced category response');
I get this error message: Expected one output from a curly brace or dot indexing expression, but there were 2 results.
I suspect that has something to do with how the function bar works in the background. Anyone has any idea how to solve this issue?
  댓글 수: 4
jonas
jonas 2020년 7월 6일
then I suspect that is where the error is ;)
Mingjia Hu
Mingjia Hu 2020년 7월 6일
Now I get this error:
Error setting property 'YLabel' of class 'Axes':
Value must be 'matlab.graphics.Graphics'.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 7월 6일
편집: Fangjun Jiang 2020년 7월 6일
because your data is 4x2, h is an 1x2 array so you can't use h.YLabel. Check the value of h
You have to use h(1).YLabel but then 'YLabel' is not a valid property
  댓글 수: 6
jonas
jonas 2020년 7월 6일
Sorry, I always forget the .String field :)
Mingjia Hu
Mingjia Hu 2020년 7월 6일
Thank you guys. Problem solved!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by