3D bar plot, does not show solid bars

i am using bar3 to do the 3D bar plots
when I use log scale for the z axis, only the top face of the 3D bar (say cuboid) shows, the rest of the bar is invisible,
figure;
bar3(err_data(:,:,2))
set(gca,'ZScale', 'log');
this does not happen on removing log scale
figure;
bar3(err_data(:,:,2))

답변 (2개)

Thorsten
Thorsten 2025년 4월 29일

1 개 추천

Try
bar3(log(errdata(:,:,2)))

댓글 수: 2

Yugal
Yugal 2025년 4월 29일
Thanks! @Thorsten
But still theres a problem
all the bars does not start from same level in z-axis, so not easy to compare
I got a solution
figure;
bar3(log10(err_Cs(:,:,2))-5)
% set(gca,'ZScale', 'log');
I shifted the positve bars to negative side by subtracting all the bars z data by 5 units.

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

Walter Roberson
Walter Roberson 2025년 4월 29일

1 개 추천

You have negative z data. When you set(gca,'ZScale', 'log') then any shape that has a vertex with negative Z cannot be rendered. Remeber that the log() of negative data is pi*1i plus log(-1*data) and renderers cannot handle the imaginary component of the resulting vertices.

댓글 수: 3

I dont have negative data,
err_Cs(:,:,2) =
299.1015 299.1228 299.1228 299.1228 299.1228 299.1228 299.1228 299.1228 299.1228 299.1228
201.7229 203.9534 204.4003 204.4049 204.4049 204.4049 204.4049 204.4049 204.4049 204.4049
102.9769 104.5377 110.2964 112.4276 112.5449 112.5454 112.5454 112.5454 112.5454 112.545
bar3(err_Cs(:,:,2))
set(gca,'ZScale', 'log');
Yugal
Yugal 2025년 4월 30일
@Walter Roberson that negative comes after taking the log of actual error (e.g. log10(0.1) = -1, like that)
The data itself doesnt have any negative values.

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

릴리스

R2024a

질문:

2025년 4월 29일

댓글:

2025년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by