Cannot zoom x axis properly with multiple 2D plots in same figure - linkprop?

2 views (last 30 days)
I cannot figure out how to get the x axis to zoom properly. Y axis works fine because all of the y data is the same scale. But because I am plotting different xlim per plot linkaxes just can seem to do it. I have tried working with linkprop to no avail either, although maybe the answer is buried in there somewhere. I tried to simplify my code for posting but thought you might as well get it all and the data too, so links are provided. Any insight is appreciated.
data.png = Link to my plot
data.mat = Link to my data
figure
axesPosition = [.032 .01 .955 .99];
axes('position',axesPosition,'xtick',[],'ytick',[],'xTickLabel',{},'yTickLabel',{});
h = [];
for i = 1:size(disColWant,2)-1 + size(ctdColWant,2)-1;
if i <= size(disColWant,2)-1;
h(i) = axes('position',axesPosition);
plot(h(i), disNumData(:,disColNum(:,i+1)),...
(disNumData(:,(disColNum(:,1))))*-1,...
'linestyle',Config.LineStyle.(disColWant{i+1}),...
'color',Config.Color.(disColWant{i+1}),...
'marker',Config.MarkerStyle.(disColWant{i+1}),...
'markersize',Config.MarkerSize);
set(gca,'xlim',Config.Scale.(disColWant{i+1}),...
'ylim',Config.Scale.(disColWant{1}),...
'visible','off');
else h(i) = axes('position',axesPosition);
plot(h(i),ctdNumData(:,ctdColNum(:,i-11)),...
(ctdNumData(:,(ctdColNum(:,1))))*-1,...
'linestyle',Config.LineStyle.(ctdColWant{i-11}),...
'color',Config.Color.(ctdColWant{i-11}),...
'marker',Config.MarkerStyle.(ctdColWant{i-11}),...
'markersize',Config.MarkerSize);
set(gca,'xlim',Config.Scale.(ctdColWant{i- 11}),...
'ylim',Config.Scale.(ctdColWant{1}),...
'visible','off');
end
end
linkaxes(h,'y')

Accepted Answer

Walter Roberson
Walter Roberson on 16 Jun 2011
Create a zoom mode object for the figure. Use a ButtonDownFilter to filter out requests that are not over any of the axes. Create a ActionPostCallback that figures out which axes was zoomed and then goes around to all of the other axes and does appropriate setting of the axes limits for them.
Or instead of using ButtonDownFilter and having to figure out which axes it was, you could (depending on what else you need to do) set HitTest off on all of the objects in all of the axes, leaving only a single axes (but not its children) with HitTest on. The zoom would then be known to be against that one axes, so you could skip the ButtonDownFilter and checking of which axes was touched and go ahead and set the xlim appropriately for all of the other axes.
  4 Comments
ruprecht precht
ruprecht precht on 17 Jun 2011
Thanks for sticking with this. You are correct, the x axes do not matter when plotting, but it would be convenient if the datacursor function was an option. As it is now however, x values do not matter as their relative positions are being analysed subjectively. Scaling all the xlims could definitely work, but how I would actually go about that will take me some time to wrap my head around. You wouldn't have a suggestion would you?
ruprecht precht
ruprecht precht on 17 Jun 2011
I have decided to skip the x axes dilemma altogether. Thanks a lot for your insight.

Sign in to comment.

More Answers (0)

Categories

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