I would like to change the linewidth of the marker independent from the linewidth of the plotted solid line. By now (see code) I am able to change it in the plot itself.
The legend however is a problem.
At the end of my script I would like to export the figure as a .eps file. If I am using the print()
function, the linewidth of the marker is always changing back (to the unwanted thicker linewidth) in the legend.
Can anybody help me to fix it that the linewidth of the marker in the plot and legend does have the correct (thiner) linewidth (as the solid line)?
clear all
clc
close all
figure(1)
p1 = plot([1,2,3,4,5,6],[5,4,6,2,4,9],'Marker','o','MarkerSize',12,'MarkerEdgeColor','r', 'LineWidth',3);
hold on
p2 = plot([1,2,3,4,5,6],[9,1,3,4,7,7], 'Marker','+','Markersize',12,'markeredgecolor','r', 'LineWidth',4);
lgd = legend([p1 p2],{'data1','data2'});
drawnow
p1.MarkerHandle.LineWidth = 1.0;
lineEntry = findobj(lgd.EntryContainer, 'Object',p1);
entryMarker = findobj(lineEntry.Icon.Transform, 'Description','Icon Marker');
entryMarker.LineWidth = 1.0;
print(figure(1),'output_fig1','-depsc','-r300')
clear all
is bad practice. It clears a whole lot more than just the workspace, and causes subsequent code to run slower. Just doclear
to clear the workspace.