How to customize the markers of the scatter figure, as shown below
43 次查看(过去 30 天)
显示 更早的评论
How to use matlab to reproduce the following scatter figure?
As shown below:
0 个评论
采纳的回答
Matt J
2024-11-14,20:49
编辑:Matt J
2024-11-14,22:06
Here's one way. Not sure you'll like the gymnastics that it requires:
[x,y]=deal(rand(1,40), rand(1,40)); %scattered input data
scatterCustom(x,y)
function scatterCustom(x,y)
%%Create marker prototypes
t=linspace(-pi/2,pi/2,1000)';
t(end+1)=t(1);
p=polyshape([cos(t),sin(t)]/35);
q=rotate(p,180);
f=@(zz,xx,yy) arrayfun(@(u,v) translate(zz,u,v),xx,yy); %translator
%%Plot
plot(f(p,x,y),FaceColor='b');hold on;axis equal
plot(f(q,x,y),FaceColor='none');hold off
end
更多回答(1 个)
Walter Roberson
2024-11-14,20:42
编辑:Walter Roberson
2024-11-14,20:44
Unfortunately, markers are only customizable between a limited number of pre-set shapes.
You will need to patch(), as I recently described in https://www.mathworks.com/matlabcentral/answers/2164720-how-to-add-pattern-fill-to-markers-in-scatter-plot#answer_1542590
Or I suppose you could use fill()
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!