Resizing Callbacks with invisible figures
古いコメントを表示
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:
- 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?
- 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 件のコメント
Jan
2019 年 6 月 26 日
Relying on a children with a specific index is not stable. Prefer to use the real handle instead of src.Children(3).
Please explain, what you observe. "The invisible axes don't scale like the other axes." Mentioning, what you not observe is less useful.
"while the second is a bar plot, drawn with the intention of creating a color code for an img plotted on the same space." - Too many details are confusing. A minimal working example as code would be more clear here.
"In the event I can't get the two axes to scale identically, I need to make this callback work slighty differently." - In which event and what does "scale" mean exactly? Which Units do the axes have?
What ist "making the function invisible"? "leads to the callback being disabled for some reason" - which callback and why do you assume, that it is "disabled"?
aboharbf
2019 年 6 月 26 日
Walter Roberson
2019 年 6 月 26 日
There are some internal values including resize related, which are not recalculated until the relevant object is made visible. This is for efficiency, so that you can change a number of properties in sequence, including temporarily having inconsistent properties, without triggering a recalculation after every change.
aboharbf
2019 年 7 月 1 日
Walter Roberson
2019 年 7 月 1 日
Is there a way around this?
There is no documented away around it.
Everything about how these things are calculated is hidden inside built-ins or inside .p files, so it is rather difficult to figure out what is happening internally.
aboharbf
2019 年 7 月 1 日
Jan
2019 年 7 月 2 日
Instead of an invisible figure, I use a figure outside the visible area of the screens sometimes. This enables some rendering, but e.g. screenshots of this figure do not work with standard methods.
Yair Altman
2019 年 7 月 5 日
In my experience, callbacks and rendering often work better and in a more consistent manner when the figure is placed off-screen while being visible (for example, hFig.Position=[-1000,-1000,100,100]), rather than being non-visible. When the rendering changes are done, you can bring the figure back to its visible position in the main monitor.
aboharbf
2019 年 7 月 7 日
Jan
2019 年 7 月 8 日
"it doesn't seem like it accepts arguments pairs" - Please post the code and show us, what let you assume, that arguments are not accepted. openfig() does not do any magic and you can inspect the code and modify a copy to satisfy your needs.
I do not understand the difference between: "make it visible on screen, then move and resize" and "make it visible, resize, then invisible". It is also not clear to me, why tic/toc matters here: If a code does not do, what you need, why does its speed play any rule? Did you include a drawnow insice the tic/toc?
aboharbf
2019 年 7 月 10 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!