I am looking to group objects together in a plot legend

3 views (last 30 days)
Hello,
I am plotting Arctic Sea Ice area against cumulative emissions, and have 24 curves (model runs) from 5 (five) cumulative emissions groups (1000, 2000, 3000, 4000, and 5000 GtC). What I want to do is group all the runs together which are from the same cumulative emissions group (which I've done by specifying the same colour for runs from a particular cumulative emissions group). Thus it would be best to have one legend entry for each cumulative emissions group (rather than a legend entry for each run!).
My current plot structure (minus the legend script) is as follows:
plot(CumEmFAST1000SVV,SVbar,'b',CumEmVFAST1000SVV,SVbar2,'b',CumEmOVST1000SVV,SVbar4,'b',CumEmFAST2000SVV,SVbar6,'g',CumEmMEDIUM2000SVV,SVbar7,'g',CumEmSLOW2000SVV,SVbar8,'g',CumEmOVST2000SVV,SVbar9,'g',CumEmFAST3000SVV,SVbar11,'k',CumEmMEDIUM3000SVV,SVbar12,'k',CumEmSLOW3000SVV,SVbar13,'k',CumEmOVST3000SVV,SVbar14,'k',CumEmFAST4000SVV,SVbar16,'m',CumEmMEDIUM4000SVV,SVbar17,'m',CumEmSLOW4000SVV,SVbar18,'m',CumEmOVST4000SVV,SVbar19,'m',CumEmFAST5000SVV,SVbar21,'c',CumEmMEDIUM5000SVV,SVbar22,'c',CumEmSLOW5000SVV,SVbar23,'c',CumEmOVST5000SVV,SVbar24,'c')
set(gca,'FontSize',15,'fontWeight','bold')
set(findall(gcf,'type','text'),'FontSize',15,'fontWeight','bold')
xlabel('Cumulative Emissions (GtC)')
ylabel('Northern Hemisphere Sea Ice Area (m ^2)')
title('Average September NH Sea Ice Area (2000-2500) for the 1000-5000 GtC scenarios')
SVBar, SVBar2, ..., SVBar24 are the sea ice area curves, and CumEmFAST1000SVV, CumEmVFAST1000SVV, ..., CumEmPULSE5000SVV refer to the corresponding cumulative emission values.
My idea is to have the following items grouped together within the legend, using the following legend entries (1000 GtC, 2000 GtC, 3000 GtC, 4000 GtC, 5000 GtC):
1000 GtC: SVBar, CumEmFAST1000SVV SVBar2, CumEmVFAST1000SVV SVBar4, CumEmOVST1000SVV SVBar5, CumEmPULSE1000SVV
2000 GtC: SVBar6, CumEmFAST2000SVV SVBar7, CumEmMEDIUM2000SVV SVBar8, CumEmSLOW2000SVV SVBar9, CumEmOVST2000SVV SVBar10, CumEmPULSE2000SVV
3000 GtC: SVBar11, CumEmFAST2000SVV SVBar12, CumEmMEDIUM2000SVV SVBar13, CumEmSLOW2000SVV SVBar14, CumEmOVST2000SVV SVBar15, CumEmPULSE2000SVV
4000 GtC: SVBar16, CumEmFAST4000SVV SVBar17, CumEmMEDIUM4000SVV SVBar18, CumEmSLOW4000SVV SVBar19, CumEmOVST4000SVV SVBar20, CumEmPULSE4000SVV
5000 GtC: SVBar21, CumEmFAST5000SVV SVBar22, CumEmMEDIUM5000SVV SVBar23, CumEmSLOW5000SVV SVBar24, CumEmOVST5000SVV SVBar25, CumEmPULSE5000SVV
I am not certain, however, how to set up my legend script to group the legend entries together?

Answers (0)

Community Treasure Hunt

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

Start Hunting!