Hi,
I am trying to plot 3D bar graph with x_true , y_true coordinates and error percentage. I tried stem, meshgrid, bar3 etc, but not able to do so. can anyone assist me to plot the graph?
figure
x_pred = Net_Out(1,:);
y_pred = Net_Out(2,:);
%
x_true = correct_output(:,1);
y_true = correct_output(:,2);
err = sqrt((x_pred - x_true).^2 + (y_pred - y_true).^2);
figure
meshgrid(x_true, y_true, err);
% figure
% percent_er = 100*errorbar((x_pred - x_true),(y_pred - y_true),err);
% figure
% bar3(err)

답변 (1개)

Drishan Poovaya
Drishan Poovaya 2021년 11월 1일

0 개 추천

I understand you want to create 3D plot of the errors vs x_true and y_true.
First of all, based on the code you have provided, the dimensions of x_pred and y_pred do not match those of x_true and y_true.
You can try evaluating x_pred and y_pred as below
x_pred = (Net_Out(1,:))';
y_pred = (Net_Out(2,:))';
For this kind of plot, using stem3 would provide the kind of plot you are expecting
stem3(x_true, y_true, err);
Documentation :

댓글 수: 5

Jaspreet Kaur
Jaspreet Kaur 2021년 11월 3일
thank you so much for this. Is it possible if you can tell me how to bar graph instead of line ?
Bar3 would not work in this case. However, to get the visual appearance of bars, you can modify stem3
stem3(x_true, y_true, err,'Marker','none', 'LineWidth', 4)
Try different values for LineWidth as needed
Jaspreet Kaur
Jaspreet Kaur 2021년 11월 8일
can you guide me how add colormap according to the height of erro bars?
Drishan Poovaya
Drishan Poovaya 2021년 11월 12일
It requires a bit of a workaround, but the answer below does what you are asking for
Jaspreet Kaur
Jaspreet Kaur 2021년 11월 29일
I am trying to get surface plot with same data showe earlier. can you help ?
x_pred = (Net_Out(1,:))';
y_pred = (Net_Out(2,:))';
x_true = correct_output(:,1);
y_true = correct_output(:,2);
err = sqrt((x_pred - x_true).^2 + (y_pred - y_true).^2);
figure
stem3(x_true, y_true, err,'Marker','none', 'LineWidth', 1)
xlabel('x'); ylabel('y'); zlabel('err');
surf (x_true, y_true, err)

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2021년 10월 29일

댓글:

2021년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by