Legends with multiple rows in Matlab

2019-08-17 05:22发布

问题:

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);

回答1:

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.



标签: matlab legend