Scatter plot changes markers when using 'filled' option

71 views (last 30 days)
I am using scatter plot and for some reason when I use the "filled" option, the marker shapes change to squares. Here is an example of my code:
scatter(T{:,i},height(T):-1:1,20, 'filled')
In this case, I am just plotting the entries for a particular table column, T{:,i}, against the row numbers. When I execute this code, the marker shapes are squares. However, if I use the longer form, I get filled circles:
scatter(T{:,i},height(T):-1:1,20, 'MarkerFaceColor', lines(1))
The drag here is that I have to know which color I am using rather than simply having the markers automatically filled with the matching color. Has anyone else ever experienced this?
  2 Comments
njj1
njj1 on 10 Feb 2020
Edited: njj1 on 10 Feb 2020
Ah, I see. Once I changed my marker size to 30, the circles appeared. It is still kinda odd that when I used "MarkerFaceColor" with a size 20, I still got circle markers, but with "filled" they appear to be square. I wonder if "filled" changes the marker size or something along those lines.
Adam Danz
Adam Danz on 10 Feb 2020
Edited: Adam Danz on 10 Feb 2020
I moved my comment as an answer and expanded upon it. Long story short, the marker edges are included when you use the "MarkerFaceColor' and those edges smooth out the rigid scatter points.

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 10 Feb 2020
Edited: Adam Danz on 10 Feb 2020
The shape of "filled" scatter points aren't necessarily changing to a square, although at some marker sizes it does appear to be a square. Change the SizeData property and you'll see that "filled" markers change shape. The marker size for scatter points specify the marker area in points squared which may partially explain the lack of consistency in shape. Monitor resolution may also factor in.
The reason the markers may appear less rigid when MarkerFaceColor is applied is because the marker edges are also applied and they smooth out the rigidity.
This demo below compare 5 scatter point sizes across the three conditions. You'll notice that the "filled" and the "MarkerFaceColor without edges" appear the same.
% Reproduce the plot above.
clf()
hold on
markerSizes = 20:20:100;
scatter(1:5, ones(1,5)+2, markerSizes, 'b', 'filled')
scatter(1:5, ones(1,5)+1, markerSizes, 'MarkerFaceColor', 'b')
scatter(1:5, ones(1,5)+0, markerSizes, 'MarkerFaceColor', 'b','MarkerEdgeColor', 'none')
xlim([-4, 10])
ylim([-4,8])
% use FEX function: https://www.mathworks.com/matlabcentral/fileexchange/46891-labelpoints
labelpoints(1:5, ones(1,5)+2, markerSizes, 'N', 0.1)
labelpoints(1, [3,2,1], {'filled','MarkerFaceColor', 'MarkerfaceColor w/o edges'}, 'W', 0.2)

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!