Multiple plots - change x axes all at once once

0
I have multiple figures where most of it is parameter vs time and the rest are scatter plots. Each figure, may contain multiple plots (only the relevant points over the same time).
Id like to change the selected time and all the figures would update accordingly.
What is the best way to do it rather to regenerate all the plots from scratch?
PS: I am using R14 version (don't ask why....)

Answers (2)

Voss
Voss on 28 Feb 2024
Moved: Voss on 28 Feb 2024

5 Comments

I am not sure that linkaxes existed in R14.
FWIW: doc says "Introduced before 2006a"
I'm familiar with this one. I'm using it on same figure where i have subplots.
But it doesn't help with scatter plots.
What's the problem using linkaxes with scatter plots in R14?
There is no problem in using linkaxes with scatter plots
figure(1)
s(1) = subplot(1,2,1); scatter(1:10, rand(1,10)*120);
s(2) = subplot(1,2,2); scatter(5:10, rand(1,6)*200);
figure(2)
s(3) = subplot(1,4,1); scatter(3:9, rand(1,7)*500);
s(4) = subplot(1,4,2); scatter(14:20, rand(1,7)*32);
s(5) = subplot(1,4,3); scatter(1:7, rand(1,7)*100);
s(6) = subplot(1,4,4); scatter(-9:-3, rand(1,7)*-10);
linkaxes(s,"x")
xlim([-20 40])

Sign in to comment.

set(HANDLES_TO_CHANGE, {'XData'}, repmat({NEW_X_VALUES}, size(HANDLES_TO_CHANGE,1), 1));

5 Comments

michael
michael on 29 Feb 2024
Edited: michael on 29 Feb 2024
Can you give example on this? What about Scarlett plots?
I have not heard of Scarlett plots.
HANDLES_TO_CHANGE(1) = plot(1:10, rand(1,10));
hold on
HANDLES_TO_CHANGE(2) = plot(18:27, -27:-18);
NEW_X_VALUES = 5:14;
set(HANDLES_TO_CHANGE, {'XData'}, repmat({NEW_X_VALUES}, size(HANDLES_TO_CHANGE,1), 1));
Of course, if the XData are all the same, you don't need to bother with the cell array syntax.
set(HANDLES_TO_CHANGE, 'XData', NEW_X_VALUES);
works just as well.
In your example you use some plots in same figure
I'm talking that you have 20 figures, each one have couple of subplots and i'd like to synchronize all of them.
In the subplots in the same figure i already use linkaxes to sync the subplots to the same x axes
linkaxes works for axes in different figures, at least when I tested it in R2022a before posting my answer. I'm not sure about R14. Are you saying that you tried to use linkaxes to synchronize axes in different figures in R14 and it didn't work?

Sign in to comment.

Products

Release

R14SP2

Tags

Asked:

on 28 Feb 2024

Commented:

on 29 Feb 2024

Community Treasure Hunt

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

Start Hunting!