MATLAB Answers

Resizing Callbacks with invisible figures

6 views (last 30 days)
aboharbf
aboharbf on 26 Jun 2019
Commented: aboharbf on 10 Jul 2019
I'm running into an issue where I've attached the following to a figure:
figHandle.SizeChangedFcn = @(src,event) set(src.Children(3),'Position',get(src.Children(end),'Position'));
The goal of this is to move a specific element (in this case, a legend), in line with a second element (another legend for the primary axes). If relevant, the idea is to move the legend of an invisible axes in line with the legend already associated with the visible one. I have two questions:
  1. The invisible axes don't scale like the other axes. The first is one with many lines plotted on it, while the second is a bar plot, drawn with the intention of creating a color code for an img plotted on the same space. the reason for this legend related callback is because for whatever reason, I can't make the axes scale identically. Is there some content I can load into the invisible axes that will solve this?
  2. In the event I can't get the two axes to scale identically, I need to make this callback work slighty differently. At the moment, making the function invisible leads to the callback being disabled for some reason - is there another callback which I may be able to take advantage of, which is triggered in the event of a resizing (or which I can enable to be so) which is not influenced by figure visibility.
Any help would be appreciated
  11 Comments
aboharbf
aboharbf on 10 Jul 2019
Code below:
for ii = 1:length(figsToPlot)
figHand(ii) = openfig(figsToPlot{ii});
figHand(ii).Units = 'inches';
figHand(ii).Position = [24 24 pageLayout{ii}.*pageSize];
end
I'd rather avoid modifying openfig, insofar as If I download a new version of MATLAB on another machine, I'd rather this not break. Ultimately, the reason I wanted to open the figures invisibly was to save time when I'm running this on many figures.
What I meant by the sequence of explanations was the code above is faster than the code below.
for ii = 1:length(figsToPlot)
figHand(ii) = openfig(figsToPlot{ii});
figHand(ii).Units = 'inches';
figHand(ii).Position(3:4) = [pageLayout{ii}.*pageSize];
figHand(ii).Visible = 'off'
end
both fragments of code achieve something very similar, but the former is faster. I don't mind the figures being visible as long as it doesn't slow down anything, which seems to be the case when you place them off the screen.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!