% plotMod.m
%
% This script uses handle graphics to modify the appearance of the current
% axis. Note that for clarity, more variables than necessary are used in 
% this code. In general, the handles and properties could be retrieved and
% used immediately rather than saved and used just once on a following
% line.
%
% Created by Dr. C. S. Tritt, 11/15/10 (v. 1.0)

clear, clc; % Clear the workspace and command window. Leave figure open.

% Get the necessary handles and store these in convenient variables.

hAxes = gca(); % Get the handle of the current axes.
pAxes = get(hAxes); % Get the properties of the axes.
hTitle = pAxes.Title; % Store the handle of the title.
hXLabel = pAxes.XLabel;% Store the handle of the X label.
hYLabel = pAxes.YLabel;% Store the handle of the X label.
hLine = pAxes.Children; % Store the line handles (children of the axes).

% Conditionally modify the title and label colors.

tColor = get(hTitle, 'Color');
if sum(tColor) == 0 % if black.
    set(hTitle, 'Color', [1, 0, 0])
else
    set(hTitle, 'Color', [0, 0, 0])
end

xlColor = get(hXLabel, 'Color');
if sum(xlColor) == 0 % if black.
    set(hXLabel, 'Color', [0, 1, 0])
else
    set(hXLabel, 'Color', [0, 0, 0])
end

ylColor = get(hYLabel, 'Color');
if sum(ylColor) == 0 % if black.
    set(hYLabel, 'Color', [0, 0, 1])
else
    set(hYLabel, 'Color', [0, 0, 0])
end

% Conditionally modify the line width. Don't assume a number of lines.

for n = 1:length(hLine) % each line...
    width = get(hLine(n), 'LineWidth'); % Get the current width.
    if width < 3 % if narrow, make it wider.
        width = width + 3;
    else % make it narrower.
        width = width - 3;
    end
    set(hLine(n), 'LineWidth', width); % This actually changes the line.
end