Page 127 - Basics of MATLAB and Beyond
P. 127

>> set(gcf,’units’)
                               [ inches | centimeters | normalized | points | pixels ]

                               We want to set the units to be normalized: the extremities of the screen
                               will correspond to zero and one.

                               >> set(gcf,’units’,’norm’)
                               >> get(gcf,’units’)
                               ans  =
                               normalized

                               The position of the figure in these new normalized units is
                               >> get(gcf,’position’)
                               ans  =
                                   0.2517     0.4933    0.4861     0.4667
                               This position vector is of the form [left bottom width height].To
                               create the two figures we first set the position property of this figure to
                               occupy the lower left corner of the screen:



                               set(gcf,’pos’,[0 0 .5 .5])



                               We create the other figure and set its position property at the same time:






                               figure(’units’,’norm’,’pos’,[.5 0 .5 .5])





                                    Exercise 14 If you look carefully at the two figures you have cre-
                                    ated in this example, you might notice that the borders of the win-
                                    dows overlap. The reason is that the figure’s position property
                                    only applies to the area contained within the figure and not to the
                                    borders supplied by the computer’s windowing system. Assume
                                    that these borders are 5 pixels wide on the left, right and bottom
                                    edges and 10 pixels wide on the top edge. Write some code to cre-
                                    ate three figures occupying exactly the bottom-left, bottom-right,
                                    and top-right quarters of the screen, with no gap between them or
                                    overlap. (The command close all might come in handy when
                                    experimenting with figure creation.) (Answer on page 190.)





                               c   2000 by CRC Press LLC
   122   123   124   125   126   127   128   129   130   131   132