How to subplot 2 constellations with scatterplot (and NOT "scatter plot")
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Louis Tomczyk
el 24 de Mayo de 2022
Comentada: Louis Tomczyk
el 25 de Mayo de 2022
Dear all,
I am trying to plot constellations (numerical communications).
The attached file (test.mat) give 4 matrices: the waveformi with i=1,2,3,4 from which we reconstruct the signal.
I would like to plot in a SAME figure using the built-in function "scatterplot".
How do the trick with the "scatterplot" and subplots built-in functions?
(I want to precise, I DON'T WANT to use "scatter plot"..
I know how to do a "hand-made" scatter plot with real an imaginary parts, but we need to normalise and work the layout by hand...)
Thanks in advance!
The small code is:
% loading the measured data
load test.mat
% reconstruction of the signals
x = waveform1+1i*waveform2;
y = waveform3+1i*waveform4;
% plotting
figure
subplot(1,2,1)
scatterplot(x)
subplot(1,2,2)
scatterplot(y)
0 comentarios
Respuesta aceptada
Voss
el 24 de Mayo de 2022
As far as I can tell, there is no way to use scatterplot to create a scatter plot in a subplot (or in any axes other than the one scatterplot creates), but maybe the following approach can work. The idea is to create the scatter plots using the scatterplot function, then copy the graphics objects to a common figure.
% loading the measured data
load test.mat
% reconstruction of the signals
x = waveform1+1i*waveform2;
y = waveform3+1i*waveform4;
% figure where two scatterplots will end up:
f = figure('Color',[0 0 0]);
scatter_fig = scatterplot(x); % create scatterplot
copyobj(get(scatter_fig,'Children'),f); % copy everything from scatterplot figure to f
delete(scatter_fig); % delete scatterplot figure
scatter_fig = scatterplot(y); % create scatterplot
copyobj(get(scatter_fig,'Children'),f); % copy everything from scatterplot figure to f
delete(scatter_fig); % delete scatterplot figure
% re-position the two axes in figure f:
ax = findall(f,'Type','axes');
set(ax(2),'Position',[0.1 0.11 0.38 0.815]);
set(ax(1),'Position',[0.6 0.11 0.38 0.815]);
3 comentarios
Voss
el 24 de Mayo de 2022
You're welcome!
I agree the solution I came up with is not very general. However, it's possible to adapt the last part, where the axes' Positions are set:
% re-position the two axes in figure f:
ax = findall(f,'Type','axes');
set(ax(2),'Position',[0.1 0.11 0.38 0.815]);
set(ax(1),'Position',[0.6 0.11 0.38 0.815]);
to handle any number and arrangement of axes, similar to how subplot does it.
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!