필터 지우기
필터 지우기

Unrecognized method, property, or field 'value' for class 'matlab.gr​aphics.cha​rt.primiti​ve.Bar'.

조회 수: 75 (최근 30일)
I am getting the following error for the code below: Unrecognized method, property, or field 'orig_short_position' for class 'matlab.graphics.chart.primitive.Bar'. I don't know how to fix this, does anyone have any suggestion? You can find origBar_input attached
% Displaying the 20 position dates with the highest frequency of appearance
origBar_input = orig_short_positionFrequency(1:20, [1 3]);
bar(origBar_input.orig_short_position, origBar_input.percentage);
origBar_input.Parent.XTick = 1:size(origBar_input, 1);
origBar_input.Parent.XTickLabel = origBar_input.orig_short_position;
origBar_input.Parent.XTickLabelRotation = 35; % rotate labels
origBar_input.Parent.XAxis.FontSize = 7; % reduce font size fo better visualization
ylabel('%')
title('Distribution of orig short position Frequency')

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 10월 26일
It looks like the code shared here is not the same code that created that error. Can you check that you copied the correct code? Also, please copy the entire error message (all the red text).
What version of MATLAB are you using?
I can recreate your error message if I create a graphics object to the bar plot using the same variable name as your table. If that is what you did, giver your bar object a different name.
load origBar_input.mat
%vvvvvvvvvvvv -----> Use a unique variable name
origBar_input = bar(origBar_input.orig_short_position, origBar_input.percentage);
origBar_input.Parent.XTick = 1:size(origBar_input, 1);
%vvvvvvvvvvvv <----------------> vvvvvvvvvvvvv Using same name
origBar_input.Parent.XTickLabel = origBar_input.orig_short_position;
Unrecognized method, property, or field 'orig_short_position' for class 'matlab.graphics.chart.primitive.Bar'.
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2021년 10월 26일
load origBar_input.mat
b = bar(origBar_input.orig_short_position, origBar_input.percentage);
b.Parent.XTick = 1:size(origBar_input, 1);
b.Parent.XTickLabel = origBar_input.orig_short_position;
b.Parent.XTickLabelRotation = 35; % rotate labels
b.Parent.XAxis.FontSize = 7; % reduce font size fo better visualization
ylabel('%')
title('Distribution of orig short position Frequency')
chiefjia
chiefjia 2021년 10월 27일
편집: chiefjia 2021년 10월 27일
Dear Cris,
yes, that's exactly the error that I'm getting, so the way to fix it is just changing the name of the bar plot to something different to origBar_input? Also, I don't understand way the bars in the plot are so narrow, since when applying exactly the same code to other values of the x label, the bar plots are thicker and the values of each one of the bins in the x axis show. You can find the example of what I mean in the figure attached.
PD: Solved it and found out it was because I didn't convert
origBar_input.orig_short_position
into a categorical
Thank you in advance.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by