|
16 | 16 | % specifying a region in terms of top-left coordinate, width and height. One box is
|
17 | 17 | % drawn for each row of BOX which is [xleft ytop width height].
|
18 | 18 | %
|
| 19 | +% |
| 20 | +% H = PLOT_ARROW(...) as above but returns the graphics handle of the arrow. |
| 21 | +% |
19 | 22 | % Options::
|
20 |
| -% 'edgecolor' the color of the circle's edge, Matlab color spec |
21 |
| -% 'fillcolor' the color of the circle's interior, Matlab color spec |
| 23 | +% 'edgecolor' the color of the circle's edge, MATLAB ColorSpec |
| 24 | +% 'fillcolor' the color of the circle's interior, MATLAB ColorSpec |
22 | 25 | % 'alpha' transparency of the filled circle: 0=transparent, 1=solid
|
23 | 26 | %
|
24 |
| -% - For an unfilled box any standard MATLAB LineStyle such as 'r' or 'b---'. |
25 |
| -% - For an unfilled box any MATLAB LineProperty options can be given such as 'LineWidth', 2. |
| 27 | +% - For an unfilled box: |
| 28 | +% - any standard MATLAB LineSpec such as 'r' or 'b---'. |
| 29 | +% - any MATLAB LineProperty options can be given such as 'LineWidth', 2. |
26 | 30 | % - For a filled box any MATLAB PatchProperty options can be given.
|
27 | 31 | %
|
| 32 | +% Examples:: |
| 33 | +% plot_box([0 1; 0 2], 'r') % draw a hollow red box |
| 34 | +% plot_box([0 1; 0 2], 'fillcolor', 'b', 'alpha', 0.5) % translucent filled blue box |
| 35 | +% |
28 | 36 | % Notes::
|
29 | 37 | % - The box is added to the current plot irrespective of hold status.
|
30 |
| -% - Additional options LS are MATLAB LineSpec options and are passed to PLOT. |
31 | 38 | %
|
32 | 39 | % See also PLOT_POLY, PLOT_CIRCLE, PLOT_ELLIPSE.
|
33 | 40 |
|
|
54 | 61 | %
|
55 | 62 | % https://github.com/petercorke/spatial-math
|
56 | 63 |
|
57 |
| -function plot_box(varargin) |
| 64 | +function h = plot_box(varargin) |
58 | 65 | opt.centre = [];
|
59 | 66 | opt.topleft = [];
|
60 | 67 | opt.matlab = [];
|
@@ -124,13 +131,17 @@ function plot_box(varargin)
|
124 | 131 |
|
125 | 132 | if isempty(opt.fillcolor)
|
126 | 133 | % outline only
|
127 |
| - plot(x, y, args{:}) |
| 134 | + hh = plot(x, y, args{:}) |
128 | 135 | else
|
129 | 136 | % filled shape
|
130 |
| - patch(x, y, 0*y, 'FaceColor', opt.fillcolor, ... |
| 137 | + hh = patch(x, y, 0*y, 'FaceColor', opt.fillcolor, ... |
131 | 138 | 'FaceAlpha', opt.alpha, 'EdgeColor', opt.edgecolor, args{:});
|
132 | 139 | end
|
133 | 140 |
|
| 141 | + if nargout > 0 |
| 142 | + h = hh; |
| 143 | + end |
| 144 | + |
134 | 145 | if holdon == 0
|
135 | 146 | hold off
|
136 | 147 | end
|
0 commit comments