How to draw Matlab 3d bar chart?

I want to draw bar graph in Matlab for my laboratory report. I have created this graph using MS Excel. Now, I want re-draw this graph using Matlab.
I have used this Matlab code to create the graph.
c = categorical({'Local processing(Smartphone)','Remote processing (Edge cloud)','Remote processing (Core cloud)'});
delay = [0.306072874 5463.639406 8200.806073];
bar3(c,delay);
This Matlab bar chat does not match Excel bar chart. Please help me about matlab code to redraw the bar chart in Matlab.

3 Comments

Note that the bar3 function is not listed.
But you can set the tick labels...just have to remember that it's the y-axis that is labeled (and the annoying fact that no matter the order in which you define them, ML will output categorical variables in alphabetical order unless you force otherwise).
c=reordercats(c,{'Local processing(Smartphone)', ...
'Remote processing (Edge cloud)', ...
'Remote processing (Core cloud)'}); % make desired order
hB3=bar3(c,delay,0.5);
hAx=gca;
hAx.YTickLabel=categories(c);
hAx.PlotBoxAspectRatio=[2 4 2.5];
hAx.YGrid='off';
hAx.GridColor='k';
and a manual orientation gets one to
for a start. I messed around with another poster not very long ago about the face shading but now that's escaped me...will have to go find that thread to recall just how did it...
Notice that I used a width parameter of 0.5 instead of default 0.8 to give the separation between the bars.
It's unfortunate ML labels aren't smart enough to know to self-wrap when need more room; one will either have to shorten these or introduce newlines; I've not experimented to see if that is acceptable or not. Undoubtedly it won't be as the catetorical names; it'll have to be written as text if will work at all.
If one introduces a \n into the label, internally it gets interpreted as going to the next tick mark so get the intended second line of first tick label as the label for second tick instead.

Sign in to comment.

Answers (1)

Updated code.
delay = [0.306072874 5463.639406 8200.806073];
x = categorical(["Local processing(Smartphone)" "Remote processing (Edge cloud)" " Remote processing (Core cloud)"]);
x = reordercats(x,{'Local processing(Smartphone)' 'Remote processing (Edge cloud)' ' Remote processing (Core cloud)'});
hB3=bar3(x,delay,0.5);
hAx=gca;
hAx.YTickLabel=categories(x);
camlight('left')
view(-80,15)

Products

Asked:

on 23 Jun 2018

Answered:

on 24 Jun 2018

Community Treasure Hunt

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

Start Hunting!