CS 211 Lesson 28

Graphics: Positions, Units, and Defaults

Quote:

"A set back is the opportunity to begin again more intelligently." Henry Ford

Lesson Objectives:

Lesson:

I. MATLAB Concepts

A. The Position and Units graphic object properties

% Set the position and size of a figure window in pixels - bad idea!
set(gcf(), 'Units', 'pixels');
set(gcf(), 'Position', [50 50 300 400]);

% Set the position and size of a figure window using percentages.
% Always use percentages because the values are independent of
% screen resolution.

set(gcf(), 'Units', 'normalized');
set(gcf(), 'Position', [0.25 0.25 0.5 0.5]);

B. Positioning objects within axes

Axes_handle = gca();
set(Axes_handle, 'XLim', [10 20]);
set(Axes_handle, 'YLim', [40 50]);
waitforbuttonpress();
Location = get(Axes_handle, 'CurrentPoint')

C. Positioning objects within themselves (e.g., text objects)

D. Default properties

II. Good Programming Practices

III. Algorithms

Lab Work: Lab 28

References:  Chapman Textbook: section 9.8-9.11