Problem with bar plot

조회 수: 1 (최근 30일)
Pablo Morcillo Pallarés
Pablo Morcillo Pallarés 2018년 4월 13일
댓글: Pablo Morcillo Pallarés 2018년 4월 13일
I was trying to make a plot bar as shown in the documentation web:
https://es.mathworks.com/help/matlab/ref/bar.html
c = categorical({'apples','pears','oranges'});
prices = [1.23 0.99 2.3];
bar(c,prices)
And in matlab 2018 works fine, but now i am trying that example with matlab 2014, and its not working... How can i plot a name for each one of the plots?
thanks in advance!
edit: the error message is this one:
Undefined function 'minus' for input arguments of type 'categorical'.
Error in bar (line 62) if any(sortedx(2:end)-sortedx(1:end-1) == 0)

채택된 답변

dpb
dpb 2018년 4월 13일
<Answer_259279> bar wasn't smartened-up enough to know about categorical variables for labels until later; not sure which release included it, but R2014b is too early.
  댓글 수: 1
Pablo Morcillo Pallarés
Pablo Morcillo Pallarés 2018년 4월 13일
thanks you!!! with the use of this line helps me a lot!
set(gca,'xticklabel',{'apples','oranges','pears'});

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

추가 답변 (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