Stack three area plots - MATLAB

22 ビュー (過去 30 日間)
AHMED FAKHRI
AHMED FAKHRI 2021 年 4 月 12 日
コメント済み: Star Strider 2021 年 4 月 14 日
Hi
I have the attached Excel file which contains the data for 1-base emissions 2-post REEE 3-Abatement.
I want to plot the base emissions on y-axis first versus the years on x-axis.
Then, the post-REEE and the Abatement emisisons should be plotted such that they 'eat' from the 'base' as shown in the figure for the similar data below:
Is there a way I can do that in MATLAB please ?
many thanks

採用された回答

Star Strider
Star Strider 2021 年 4 月 12 日
This approaches what you want, however there must be some sort of conservation metric or other sort of scaling necessary to get the plot to appear as you want it to appear. I must leave that to you, since I do not understand how the various emissions values are related. (I left the ‘TotalEmissions’ vector that I created in the code, in the event you want to use it.)
T1 = readtable('CCC_data_emissions.xlsx');
T2 = T1; % Duplicate & Save Original
TF1 = ismember(T2.years, T2.years_1); % Matching Years
T2.emissions_1(TF1) = T1.emissions_1(~isnan(T1.emissions_1)); % Matching Values
T2.emissions_2(TF1) = T1.emissions_2(~isnan(T1.emissions_2)); % Matching Values
TotalEmissions = T2.emissions+T2.emissions_1+T2.emissions_2;
figure
area(T1.years, [T2.emissions-T2.emissions_1-T2.emissions_2, T2.emissions_1, T2.emissions_2])
legend('Emissions','Emissions_1','Emissions_2', 'Location','NE')
.
  12 件のコメント
AHMED FAKHRI
AHMED FAKHRI 2021 年 4 月 14 日
That is brilliant, many thanks for the efforts, I will also work from my side and update you if I managed to do it.
Star Strider
Star Strider 2021 年 4 月 14 日
I very much appreciate your compliment!
As always, my pleasure!

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

その他の回答 (1 件)

Jithin Nambiar J
Jithin Nambiar J 2021 年 4 月 12 日
If you can plot the y values and x values for the 3 different ranges. You can use
hold on
after the first plot and at the end of last plot use
hold off
  1 件のコメント
AHMED FAKHRI
AHMED FAKHRI 2021 年 4 月 12 日
Hi, thanks I know how to use hold on and off but I need to plot the y values first using one scale or be able to hide other scales

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

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by