MATLAB Answers

JK
0

Cannot set marker edge thickness using the Linewidth property smaller than 1pt

Asked by JK
on 27 Oct 2018
Latest activity Answered by JK
on 1 Nov 2018
I would like to set the edge thickness of markers to some smaller values than 1 (0.5 or 0.3 for example). I currently use Matlab 2018b on a Mac and could not yet figure out why markers always appear with an edge width of 1pt. I attached an example where the lines (when exported to an eps file either via the Matlab export function or the export_fig addon) have the correction thickness but the markers seem to remain at a width of 1pt.
Edit: It seems that the Linewidth property affects the edge thickness of markers for values equal to 1 or above. Setting it to values <1 seems not to work though (only for lines, not the markers).
Thanks a lot
testpoints = line([1 2 3 4 5],[4 5 6 7 8],'LineStyle','none','Linewidth', 0.5,'MarkerEdgeColor','k','MarkerFaceColor','w','Marker','s','MarkerSize',4);
testline = line([1 2 3 4 5],[4 5 6 7 8],'LineStyle','-','Linewidth', 0.5,'Marker','none');

  2 Comments

I inspected the eps file using Adobe Illustrator and checked the line and marker thickness.

Sign in to comment.

2 Answers

Answer by jonas
on 27 Oct 2018
Edited by jonas
on 27 Oct 2018

After digging through the undocumented properties, here's how you change the marker edge thickness:
LineHandle.NodeChildren.LineWidth = 2
The edgethickness does not automatically scale with markersize, so none of your linespec properties affect the edgethickness.

  8 Comments

Okay, I figured out where the error comes from. I only changed the linewidth via the command window, but received the same error when I put it in the code. This problem is usually solved by adding a
drawnow
after the line. So...
testpoints = line([1 2 3 4 5],[4 5 6 7 8],'LineStyle','none','Linewidth', 0.5,'MarkerEdgeColor','k','MarkerFaceColor','w','Marker','s','MarkerSize',4);
drawnow
testpoints.NodeChildren.LineWidth = 0.25
indeed, the linewidth is not exported correctly. I am getting 0.75 pts in illustrator.
Yes, it seems to have the same effect as using the Linewidth property but it is not possible to reduce the marker thickness below 1pt in my case (I didn't even manage to get 0.75 as you did).
Yep you are correct, I had not noticed that the edge of the marker scales with linewidth. The only other answer I can find online is related to resolution, which is not the problem here because the axes ruler is 0.5 pts and is exported just fine. Odd.

Sign in to comment.


Answer by JK
on 1 Nov 2018

Mathworks support has now confirmed that this is a bug and forwarded it to the development team to be fixed in a future release.

  0 Comments

Sign in to comment.