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

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

3 Comments

I inspected the eps file using Adobe Illustrator and checked the line and marker thickness.
According to the documentation,
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
I do not know how this would affect eps; I suspect the plot would get rasterized according to the figure PageSize

Sign in to comment.

Answers (3)

I am having the same issue.
One not very good solution is to plot the data twice once with just the edge and another with the face. This seems to get the correct effect but it is not an optimal solution.
hold on
plot(XData, YData, ...
'o', ...
'MarkerSize', 1, ...
'MarkerEdgeColor', [31, 119, 180] / 255;
plot(XData, YData, ...
'o', ...
'MarkerSize', 0.8, ...
'MarkerEdgeColor', 'none', ...
'MarkerFaceColor', [174, 199, 232] / 255);
hold off

6 Comments

This solution is the best!
The undocumented solution might be dangerous in the long run, whereas David's solution will remain valid whatever changes done by Mathworks
@David Broadway, @jonas Please could you help with this problem
pzmap(T,'-d','MarkerSize',8)
The right command is pzmap(T), but i want to change the default marker from x to diamond and also increase the size to make it visible.
Thank you
You can change properties by looking for the corresponding line objects.
H = tf([2 5 1],[1 3 5]);
pzmap(H)
grid on
% these are the line objects for the poles and zeros
hp = findobj(gca,'tag','PZ_Pole');
hz = findobj(gca,'tag','PZ_Zero');
% set the properties of whichever you want
hp.Marker = 'd';
hp.MarkerSize = 10;
@DGM; thank you for the response. I have three matrices (5x5) of different eigenvalues, how do I designate the eigenvalues of the three matrices with
1. different marker?
2. If i want to use the same marker (very bold for clearity) but of different colour, how do i put the code?
3. is there a way i can alter my code/ to connect the eigenvalues of same matrix together?
Below is sample;
Ta1 = 24; Ta2 = 27; Ta3= 20;
H11 = -0.0641; H12 = 0.0359;
H21 = 0.1176; H22 = -0.2057;
H31 = 0.2077; H32 = 0.1961;
for D = [0 4 10]
A = [0 0 1 0 -1;0 0 0 1 -1;(-H11/Ta1) (-H12/Ta1) (-D/Ta1) 0 0;...
(-H21/Ta2) (-H22/Ta2) 0 (-D/Ta2) 0;(-H31/Ta3) (-H32/Ta3) 0 0 (-D/Ta3)];
Eig = eig(A)
a = Eig(1,1);
b = Eig(2,1);
c = Eig(3,1);
d = Eig(4,1);
e = Eig(5,1);
s = tf('s');
T = (1)/((s-a)*(s-b)*(s-c)*(s-d)*(s-e));
P = pole(T);
if D == 0
pzmap(T,'g')
end
hold on
if D == 4
pzmap(T,'y')
end
hold on
if D == 10
pzmap(T,'r')
end
hold off
end
Those marker, are not visible at all when i export to word, pls kindly help
Thank you for the guide
I'm a bit slow today. I see Walter is already working with you here
His solution thus far already includes the concepts that I've covered, so it would probably be best to focus on that thread for now.
pzmap() does not allow you to directly change properties; you have to look for the graphic objects.
pzplot() does allow you to pass in some properties, and returns a handle that allows you to directly change other properties without having to search for the objects.

Sign in to comment.

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.

9 Comments

Could you explain how to implement this in my example (for testpoints line object)?
testpoints.NodeChildren.LineWidth = 2
I receive the following error when applying it to the testpoints object:
You cannot set the read-only property 'NodeChildren' of Line.
Error in test (line 17) testpoints.NodeChildren.LineWidth = 2
Weird. Will take a second look when I get home. What release?
This property is ubdocumented, so it can be a bit buggy but it worked for me (2018a)
R2018b (9.5.0.944444), OSX High Sierra. I get the same error for both objects (testline and testpoints).
What I find confusing is that with the example code I can set the marker edge thickness to values above 1pt but not below. It seems as if there is a lower limit either from Matlab or related to the eps conversion.
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.

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

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Asked:

JK
on 27 Oct 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!