How do I display certain data on top of others using multiple Scatter plots

17 次查看(过去 30 天)
scatter(real(SGG(ids)),imag(SGG(ids)),10,[0 1 0],'filled');
hold on
for abc=1:M
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),35,[0 0 1],'filled');
end
scatter(real(SRR(idx)),imag(SRR(idx)),10,[1 0 0],'filled');
xlabel('Real Part');
ylabel('Imaginary Part');
title('ACE For MaxMin');
legend([scatter(real(SGG(ids)),imag(SGG(ids)),10,[0 1 0],'filled'), ...
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),15,[0 0 1],'filled'),...
scatter(real(SRR(idx)),imag(SRR(idx)),10,[1 0 0],'filled')],'Correct-Decoded Signal','QPSK Signal','Error-Decoded Signal');
xlabel('Real Part');
ylabel('Imaginary Part');
title('ACE For MaxMin');
hold off
The above are the codes that I used to create multiply scatter plots, but everytime the second scatterplot's data gets overlapped by the other scatterplots.
for abc=1:M
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),35,[0 0 1],'filled');
end
This is the scatter plot data that I want to display at the very top without other data overlapping it, is there a way to do that?

采纳的回答

Dave B
Dave B 2021-8-2
You can manipulate the stacking order in the axes by changing the order of the axes children vector or using the ustack function:
ax=gca;
h1=scatter(ax,rand(1000,1),rand(1000,1),100,'filled','r');
hold on
h2=scatter(ax,rand(1000,1),rand(1000,1),100,'filled','b');
ax.Children=[h1;h2]; % display the red one on top of the blue one
uistack(h1); % display the red one on top
Note: your call to legend is suspicious, it looks like you're making additional scatters (?) If you capture the output of the scatters in a variable, you can pass that variable to legend rather than calling scatter again.
  1 个评论
Steven Yeh
Steven Yeh 2021-8-3
Thanks a lot, this works perfectly, and thanks for correcting my code, the scatter in legend did seem redundant, I’ve set new variables to each scatter and everything works. Thanks a lot again!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by