Determine which function was used to generate hggroup?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone,
Is there a way to determine which function (e.g., quiver(), scatter(), contour(), etc.) was used to generate a particular hggroup? For example, suppose I have the following:
%draw some objects
f=figure();
dat = rand(20,4);
q= quiver( dat(:,1), dat(:,2), dat(:,3), dat(:,4), 0, 'blue');
hold on;
s = scatter( dat(:,1), dat(:,2), 100*dat(:,3), 'red', 'filled');
[~, c] = contour( dat, 5);
%get these objects
obj = findobj(gca, '-depth', 1, '-not', 'type','axes');
objTypes = get(obj,'type')
All of the values of 'objTypes' are 'hggroup'. Is there a way to distinguish between these various objects?
Currently, I am just checking for a property that I know exists in, for example, a quiver object but not a scatter object, to infer the function used to generate this.
quiverCorrect = obj(isprop(obj, 'AutoScaleFactor')) == q, %returns true
scatterCorrect =obj(isprop(obj, 'SizeData'))==s, %returns true
contourCorrect = obj(isprop(obj,'ContourMatrix'))==c, %returns true
However, I imagine there's a more elegant and foolproof way to do this. I inspected the children of each of these objects, but as the child objects are just lines and patches, they didn't seem to provide much insight.
Any help you can provide would be appreciated.
0 Commenti
Risposte (1)
Jan
il 21 Feb 2014
The most direct way would be to add this information by your onw:
dat = rand(20,4);
q = quiver( dat(:,1), dat(:,2), dat(:,3), dat(:,4), 0, 'blue');
setappdata(q, 'CreatorFunction', 'quiver');
You could create functions to do this automatically:
function H = quiverX(varargin)
H = quiver(varargin{:});
setappdata(H, 'CreatorFunction', 'quiver');
I'd hesitate to re-use the original name quiver in general to avoid collisions with built-in functions. But actually there should be no problem in doing this, such that even external code would call the modified function without the need to change the code.
Vedere anche
Categorie
Scopri di più su Vector Fields in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!