How to plotting a 3D bar graph from 3 sets of data

7 views (last 30 days)
Hello,
I want to be able to write a code that can essentially read a .txt file and be able to plot a bar graph that looks like this. I have been trying to use different forms of bar3 and bar3h but none of them can show up like this. Does anyone know how I can go about this task? Please I have attached a mock data file of the three things I would like to be on the axis.
  2 Comments
dpb
dpb on 22 Sep 2021
MATLAB bar plots are pretty weak, granted...really no excuse.
There's probably a real 3D bar plot routine at File Exchange but I didn't go searching.
The only way I can see with the builtin bar3() function would be to create the matrix Z with enough rows to match up with the Y axis spacing that are integral positions apart as the code is written. Then array would be NaN excepting for the areas corresponding to the data positions.
In the above LH case, if the CL of the bars in the A direction are 0.015 apart (or if that were sufficient granularity to get by), then you'd need
>> (0.4-0.1)/0.015
ans =
20.0000
>>
rows along that direction with which to be able to create that many bars in that direction -- only one of those rows would contain data other than NaN at the wanted X location.
NB: I've not tried this, just the way I think would have to go at it with the tool as it exists.

Sign in to comment.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 25 Sep 2021
Yes, it is viable to some extent what you want in MATLAB:
Z = readmatrix('Mock_Data.xlsx');
ZData=Z;
H = bar3(Z);
for ii = 1:length(H)
zdata = H(ii).ZData;
H(ii).CData = zdata;
H(ii).FaceColor = 'interp';
end

More Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!