Skip to content
Snippets Groups Projects
Commit f8bb26b0 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Figure Extras: added arrows and segments

parent 0ecfceb7
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,10 @@ function gtFigureAddExtras(ax, im_props, extras)
add_box(ax, extras{ii_ex})
case 'text'
add_text(ax, extras{ii_ex})
case 'arrow'
add_arrow(ax, extras{ii_ex})
case 'segment'
add_segment(ax, extras{ii_ex})
end
end
end
......@@ -107,6 +111,27 @@ function add_text(ax, ex_props)
'FontAngle', ex_props.font_angle, ...
'FontWeight', ex_props.font_weight, ...
'HorizontalAlignment', ex_props.alignment_horz, ...
'VerticalAlignment', ex_props.alignment_vert );
'VerticalAlignment', ex_props.alignment_vert, ...
'Interpreter', ex_props.interpreter );
end
function add_arrow(ax, ex_props)
final_dir = ex_props.direction * ex_props.line_length;
hold(ax, 'on')
quiver(ex_props.position(1), ex_props.position(2), final_dir(1), final_dir(2), 0, ...
'parent', ax, 'Color', ex_props.color, ...
'LineWidth', ex_props.line_width, 'LineStyle', ex_props.line_style)
hold(ax, 'off')
end
function add_segment(ax, ex_props)
xs_l = ex_props.position([1 3]);
ys_l = ex_props.position([2 4]);
line(xs_l, ys_l, 'parent', ax, 'Color', ex_props.color, ...
'LineWidth', ex_props.line_width, 'LineStyle', ex_props.line_style)
end
......@@ -8,6 +8,10 @@ function extras = gtFigureCreateExtras(type, varargin)
extras = create_box(varargin{:});
case 'text'
extras = create_text(varargin{:});
case 'arrow'
extras = create_arrow(varargin{:});
case 'segment'
extras = create_segment(varargin{:});
end
extras.type = type;
end
......@@ -53,6 +57,27 @@ function extras = create_text(varargin)
'font_size', 10, ...
'font_weight', 'normal', ... {'normal', 'bold', 'light', 'demi'}
'font_angle', 'normal', ... {'normal', 'italic', 'oblique'}
'color', [1 1 1], ...
'interpreter', 'tex' );
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_arrow(varargin)
extras = struct( ...
'line_length', 10, ...
'line_width', 0.5, ...
'line_style', '-', ...
'position', [1 1], ...
'direction', [1 1], ...
'color', [1 1 1] );
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_segment(varargin)
extras = struct( ...
'line_width', 1, ...
'line_style', '-', ...
'position', [1 1 10 10], ...
'color', [1 1 1] );
extras = parse_pv_pairs(extras, varargin);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment