user7420687
user7420687

Reputation:

Legends with multiple rows in Matlab

How to create a legend with multiple rows or fit a legend within the plotting area. Following is my code and output plot

figure;
col = jet(numel(node_id_without_duplicates));
%legend('Node ');

for i=1:numel(node_id_without_duplicates)
    specific_node = node_id_without_duplicates(i);
    legendInfo{i} = ['Node ', num2str(specific_node)];    
    MTBF_Specific_Node; //This is the call of an another tool created by me and not included in this example. 
end    
legend(legendInfo);

enter image description here

Upvotes: 0

Views: 1834

Answers (1)

Gryphon
Gryphon

Reputation: 549

You can use gridLegend on FEX. It uses undocumented hidden axes property ScribeLegendListeners, for details please see "Multi-column (grid) legend" on Undocumented MATLAB.

I totally agree with gnovice: the plot is overloaded, rethink it to be more helpful and informative. However, if you want readers to understand nothing and say "Wow, it seems to be a hard task" the plot is just correct.

Upvotes: 1

Related Questions