Is it possible to obtain both line and bars on the same graph?
1 次查看(过去 30 天)
显示 更早的评论
I have these vectors Years, A,B i would like to obtain a single graph with both bar(Years,B) and plot(Years,A).
How can i do this?
Years=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
A=[-8.8000 -8.5211 -8.2421 -7.9632 -7.6843 -7.4053 -7.1264 -6.8475 -6.5685 -6.2896 -6.0107 -5.7318 -5.4528 -5.1739 -4.8950 -4.6160 -4.3371 -4.0582 -3.7792 -3.5003 -3.2214];
B=[-8.8000 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189];
%I can obtain separatly graphs:
plot(Years,A);
bar(Years,B);
0 个评论
采纳的回答
Star Strider
2022-6-28
Years=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
A=[-8.8000 -8.5211 -8.2421 -7.9632 -7.6843 -7.4053 -7.1264 -6.8475 -6.5685 -6.2896 -6.0107 -5.7318 -5.4528 -5.1739 -4.8950 -4.6160 -4.3371 -4.0582 -3.7792 -3.5003 -3.2214];
B=[-8.8000 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 1.1589 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189 0.7189];
%I can obtain separatly graphs:
figure
plot(Years,A)
hold on
bar(Years,B)
hold off
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!