Scatter plot changes markers when using 'filled' option

조회 수: 66 (최근 30일)
njj1
njj1 2020년 2월 10일
편집: Adam Danz 2020년 2월 10일
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
njj1
njj1 2020년 2월 10일
편집: njj1 2020년 2월 10일
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 2020년 2월 10일
편집: Adam Danz 2020년 2월 10일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2020년 2월 10일
편집: Adam Danz 2020년 2월 10일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by