Veridian Veridian - 1 year ago 158
LaTeX Question

How can I show only the legend in MATLAB

I want to show only the legend for a group of data in MATLAB.

The reason I want to do this is that I want to export the legend to .eps, but I only want the legend, not the plots.

Is there a way to turn off the plots and remove them from the figure, but still show just the legend centered?

Answer Source

I think that you need to "hide" the elements you don't want in your plot, leaving out only the legend. For example,

clear all; close all;
figure;
p1 = plot([1:10], [1:10], '+-');
hold on;
p2 = plot([1:10], [1:10]+2, 'o--');

legend('text1', 'text2');


set(p1, 'visible', 'off');
set(p2, 'visible', 'off');
set(gca, 'visible', 'off');

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download