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

17 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Dave B
Dave B il 2 Ago 2021
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 Commento
Steven Yeh
Steven Yeh il 3 Ago 2021
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!

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by