简体   繁体   中英

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.

在此处输入图片说明

I often present my MATLAB plots and figures. It's a constant formating struggle.

I was unable to put the categories on the x-axis. I hope to come back to the problem tomorrow if no one has solved it by then.

The code below contains three major changes. First, it removes the categorical variable from the bar3() function. The categorical() function arranged the bar graph in alphabetical order, which is why your MATLAB plot differs from the Excel plot.

Second, the code uses a camlight() call to add shadows to the bar graph.

Third, a view() function is included to change the orientation of the plot.

I suggest that you look up the documentation page for any of the functions I added, in case you want to see more.

names = {'Local processing(Smartphone)','Remote processing (Edge cloud)','Remote 
processing(Core cloud)'};
c = categorical(names);
delay = [0.306072874    5463.639406 8200.806073];
b=bar3(delay);
camlight('left')
view(-80,15)

Thank you Juanchito for your valuable support. Here, is the 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)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM