フィルターのクリア

Is it possible to obtain both line and bars on the same graph?

1 回表示 (過去 30 日間)
Pietro Fiondella
Pietro Fiondella 2022 年 6 月 28 日
コメント済み: Star Strider 2022 年 6 月 28 日
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);

採用された回答

Star Strider
Star Strider 2022 年 6 月 28 日
Use the hold function
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
.
  2 件のコメント
Pietro Fiondella
Pietro Fiondella 2022 年 6 月 28 日
Thank you Star Strider!
Star Strider
Star Strider 2022 年 6 月 28 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by