How to plot specific graph

hello all
im trying to graph in a certain way and was hoping to learn how to do this. attatched is what im trying to do but not sure how to do it in matlab. thank you!!

 采纳的回答

x = 1:4;
y1 = [40 0 0 0];
y2 = [-28 0 0 0];
bar(x, y1, 'FaceColor', 'r');
hold on;
bar(x, y2, 'FaceColor', [.5 .5 .5]);
grid on;

2 个评论

hi! thanks for the response, but how do i make it so the bottom numbers are not negative? can i make that axis positive also? i'm not sure for the formatting. thank you!!
You can reset the tick labels to be anything you want, for example you could take the absolute value and write them back out as positive. Look up tick labels in the help for examples.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by