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

조회 수: 32 (최근 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