i want to have subsets in my legend
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clc
clear all
%plot oecd total energy for steps, aps, and sds
TES_historical_time=[2010 2015 2019 2020 ];
TES_historical=[231037 225604 228295 213629];
TES_time=[2030 2035 2040 2045 2050 ];
TES_steps=[215894 209431 205540 202555 200149];
TES_aps=[199887 185881 175659 169372 165899];
TES_sds=[197640 183243 170911 163577 160851];
TES_historical_time2=[2010 2015 2019 2020 ];
TES_historical2=[298652 334447 367223 362481];
TES_time2=[2030 2035 2040 2045 2050 ];
TES_steps2=[433836 461992 484446 503065 515144];
TES_aps2=[431278 456696 473180 480883 485179];
TES_sds2=[383233 389760 391694 393396 399416];
figure(1)
%oecd plots
scatter(TES_historical_time, TES_historical,"red") , xlabel('year'), ylabel('total energy supply(TES)'), title('OECD countries')
hold on
scatter(TES_time, TES_steps,"blue")
scatter(TES_time, TES_aps,"cyan")
scatter(TES_time,TES_sds,"green"),
%non_oecd plots
scatter(TES_historical_time2, TES_historical2,"red","x") , xlabel('year'), ylabel('total energy supply(TES)'), title('non-OECD countries')
scatter(TES_time2, TES_steps2,"blue","x")
scatter(TES_time2, TES_aps2,"cyan","x")
scatter(TES_time2,TES_sds2,"green","x"), legend({'historical','steps','aps','sds'}), title(legend, 'oecd (O) |non-oecd (X)')
i want to make a legend where oecd are O's and NONoecd are X's, and the colors correlate to the same labels, "historical, steps, aps, sds"
0 Kommentare
Antworten (1)
Ganapathi Subramanian
am 22 Mai 2023
Hi Joshua,
It is my understanding that you are working on plotting data and wants to know how to create legends for ‘o’ and ‘x’ points in separate columns for same labels.
legend({'historical','steps','aps','sds','historical','steps','aps','sds'},'NumColumns',2)
title(legend, 'oecd (O) |non-oecd (X)')
For further information regarding legend function refer the below documentation
0 Kommentare
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!