Multiple Scattergram plots in the same figure

1 view (last 30 days)
I would like to create two scattergram plots (Wavelet toolbox) in the same figure. I tried using the subplot command but it did not work (no error message, but only plotted the 2nd figure, not in subplot position).
scattergram(wf,Sgood,'FilterBank',vizLevel); title(good);

Accepted Answer

Adam Danz
Adam Danz on 13 Jun 2019
Edited: Adam Danz on 19 Jun 2019
The easy way
Create two different figure; then copy the axis of the second figure to the first figure and change the axis positions; then delete the second figure.
% Create first figure
fh(1) = figure();
scattergram(...);
axh(1) = gca;
% Create second figure
fh(2) = figure();
scattergram(...);
axh(2) = gca;
% Change position of 1st axis
axh(1).Position = [.07,.35,.35,.44];
% Copy axis #2 to figure 1
axh(2) = copyobj(axh(2),fh(1));
% Change position of new axis
axh(2).Position = [.55,.35,.35,.44];
% Delete second figure
delete(fh(2))
The hard way
If you look at the function in waveletScattering.m > scattergram(), it has an optional output that is the scattergram. When that output is included, the figure is not drawn. You can use that output to plot the figure in any axis you want but it comes at the cost of doing additional work that is done within the function.
The lines that create the plot are below.
if isVector
plot(AX,tstamps,cfs); grid on;
axis tight;
else
surf(AX,tstamps,F,cfs); view(0,90);
shading interp; axis tight;
end
You'll need to step through that function in debug mode to re-create the tstamps (and F) values. "cfs" is created by including the output to the scattergram function.
csf = scattergram(...);
  2 Comments
Jerome Coffey
Jerome Coffey on 1 Jul 2019
This worked for me but I needed to be in Matlab R2019A... R2017A did not like the syntax of this command:
axh(1) = gca;
Adam Danz
Adam Danz on 1 Jul 2019
Glad it worked!
The gca() command has been around since prior to 2006.
scattergram(), however, joined the club in r2018b so that line was probably the dealbreaker for you in r2017a.

Sign in to comment.

More Answers (0)

Categories

Find more on Line 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!