How to subplot 2 constellations with scatterplot (and NOT "scatter plot")
23 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Voss
on 24 May 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 Comments
Voss
on 24 May 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.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!