plot help

2 vues (au cours des 30 derniers jours)
vsee
vsee le 15 Août 2011
Hello
Here is matlab code that I am using to plot (analog and ttl signals of a waveform) and pan across the x-axis of the plot.
dsig = csvread('digital 1030 50Mhz 5M.csv',0,3);
asig = csvread('analog 1030 50Mhz 5M.csv',0,3);
%tim =sig(1:1000000,1);
damp = dsig(1:5000000,2);
aamp = asig(1:5000000,2);
ts = dsig(2,1) - dsig(1,1);
tim = [0:5000000 - 1]*ts;
time = tim';
subplot(2,1,1), plot(time, aamp);
subplot(2,1,2), plot(time, damp);
axis([0 max(tim) -0.1 1.5]);
ax_handle = gca;
xlimit_orig = get(ax_handle, 'Xlim');
win_xlimit = [0 0.0001];
offset = 0.0001;
%Iterativley change the xlimit for the axes to pan across the figure
while win_xlimit(2) <= xlimit_orig(2)
set(ax_handle, 'Xlim', win_xlimit);
pause(0.5);
w = waitforbuttonpress;
if w == 1
win_xlimit = win_xlimit + offset;
end
end
GCA seems to return axis handles to one of the plots. The panning works fine if I just plotted one signal and didn't use subplot. How can I pan across both plots using subplot?
Thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 15 Août 2011
See linkaxes()
  2 commentaires
vsee
vsee le 15 Août 2011
Thanks much. I am able to pan simultaneously. However, can I still keep axis limits separate?
Walter Roberson
Walter Roberson le 15 Août 2011
Not as easily. pan works by modifying the axes limits, and there is no built-in functionality for keeping the same _relationship_ of axes limits between two axes.
It is possible, though. Have a look at the pan() documentation. Create pan mode objects for the two axes, and set the ActionPostCallback callbacks on those pan mode objects so that when one of the axes is panned, you set() the axes limits on the other to pan it to the desired relative location. The callbacks will need to know the relative offsets to use for the _other_ axes to know how to transform the limits for the current axes in to appropriate limits for the other axes.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by