Question about "grouping" elements in figures

Question about "grouping" elements in figures

Post by Jim Rockfo » Tue, 23 Jun 2009 10:21:58


Power point has a convenient feature of being able to "group" together
various lines and arrows and things into one object. Is there such a
facility when using the figure editor in Matlab? I'm trying to make a
scale bar for a figure that looks like the following (but contiguous):

---
|
---

The arrow option doesn't seem to offer terminal endings of horizontal
lines; otherwise I'd use that. So, what I do is cobble together 3
lines and place them manually. It's a real pain, of course, if I have
to move them to another location in the figure.

Any suggestions?

Thanks,
Jim
 
 
 

Question about "grouping" elements in figures

Post by Jim Rockfo » Fri, 26 Jun 2009 05:35:15


Doesn't anyone know whether this is or is not possible?

Thanks,
Jim

 
 
 

Question about "grouping" elements in figures

Post by Steven Lor » Fri, 26 Jun 2009 06:23:16


If you're only going to be modifying properties that are common to all the
objects you want to group together, put them in a vector of handles.
Alternately, you could write your own handle object in a classdef file that
creates several Handle Graphics objects and manages their properties, like
this (very) rough example.

classdef plussymbol < handle
% This function should have more error checking, but it's simply a
% rough example. Feel free to expand upon it if you want.
%
% Example (execute each line one at a time)
% plot(1:10, 1:10);
% h = plussymbol
% h.moveme
properties
horizontalHandle
verticalHandle
centerCoord
end
methods
function h = plussymbol
h.centerCoord = ginput(1);
x = h.centerCoord(1);
y = h.centerCoord(2);
h.horizontalHandle = line(x+[-1 1], [y y]);
h.verticalHandle = line([x x], y+[-1 1]);
end
function disp(h)
fprintf('The center of this plus symbol is located at x = %g, y
= %g.\n', h.centerCoord);
end
function moveme(h)
h.centerCoord = ginput(1);
x = h.centerCoord(1);
y = h.centerCoord(2);
set(h.horizontalHandle, 'XData', x+[-1 1], 'YData', [y y]);
set(h.verticalHandle, 'XData', [x x], 'YData', y+[-1 1]);
end
end
end

--
Steve Lord
XXXX@XXXXX.COM
 
 
 

Question about "grouping" elements in figures

Post by Alan » Fri, 26 Jun 2009 06:37:01


I haven't used it before, but can't hggroup do this?

h = hggroup;
a = line(rand(1,2),rand(1,2),'parent',h);
b = line(rand(1,2),rand(1,2),'parent',h);
 
 
 

Question about "grouping" elements in figures

Post by Steven Lor » Fri, 26 Jun 2009 23:15:35


*snip*


You are correct. I haven't used HGGROUPs very often, so I completely forgot
to mention them. Good catch!

--
Steve Lord
XXXX@XXXXX.COM
 
 
 

Question about "grouping" elements in figures

Post by Jim Rockfo » Thu, 02 Jul 2009 08:26:16


Thanks for the replies guys. For the developers out there (Steven),
any chance that such a "grouping" feature could be implemented in the
figure editor in future Matlab versions? The less code writing the
better, so far as figure editing is concerned.

Best,
Jim
 
 
 

Question about "grouping" elements in figures

Post by Steven Lor » Fri, 03 Jul 2009 02:53:56


Potentially. You could increase the chance of that happening (and greatly
increase the chance that it does specifically what you want it to do if or
when it is implemented) by contacting Technical Support and giving them a
clear description of what you would expect such a "grouping" feature to be
able to do. If you do this they can capture that feedback and pass it along
as a customer request to the graphics developers.

I know your original message said you were trying to group lines together,
but is that all you would need such a grouping feature to do? Would you
need or want it to be able to group other type of graphics together (lines
with surfaces, lines with images, images with surfaces, etc.)?

You can send in your enhancement request to Technical Support using the form
linked to on this page:

http://www.yqcomputer.com/

--
Steve Lord
XXXX@XXXXX.COM