• Print  |
  • Feedback  |

Knowledge Base


TS-499

WHEN I REPLAY THREE GRAPHS INTO A TEMPLATE, THEY APPEAR DISTORTED. HOW CAN I CORRECT THIS DISTORTION?

Question:

When I replay three graphs into a template, they appear distorted. How can I correct the distortion?

Answer:

The graphs appear distorted because they were created with proportions based on the entire graphics area. These same proportions probably aren't appropriate for the dimensions of the template panels, which may be a different shape. If, when creating the graphs, you adjust the HSIZE and VSIZE values to reflect the dimensions of the template panel, then distortion in the templated graph can be avoided.

The following sample program demonstrates the problem and one solution. First, we create three graphs using the GCHART procedure. When we replay the graphs into the V3 template that is provided in the catalog SASHELP.TEMPLT, we see the distortion you noted:

    goptions target=ps hby=0
             ftext=swiss nodisplay;
    
    data one;
    
       input @1 player $10. @12 rank @14 position $;
       cards;
    TAYLOR     1 LB
    LAMBERT    2 LB
    SINGLETARY 3 LB
    SMITH      1 RB
    BETTIS     2 RB
    SANDERS    3 RB
    RICE       1 WR
    SHARPE     2 WR
    RISON      3 WR
    ;
    
    proc gchart data=one gout=work.gseg;
    
       vbar player / sumvar=rank;
    
       by position;
    
       title1 'This is a graph for #byval(position)';
       pattern1 v=solid c=black;
     run;
     quit;
    
    goptions display;
    
    proc greplay nofs igout=work.gseg tc=sashelp.templt
                   template=v3;
    
       treplay 1:GCHART
               2:GCHART1
               3:GCHART2;
     run;
     quit;
    
To resize the graphs so that they are proportioned to fit in the template panels, we must determine what HSIZE and VSIZE are being used by the device driver (in this case, the PS driver). To do this, run the GTESTIT procedure with the NODISPLAY option in effect, and then check the output that is written to the SAS log.
    goptions device=ps nodisplay;
    
    proc gtestit;
     run;
     quit;
    
The output written to the SAS log by the GTESTIT procedure will look like this:



   D=PS       B=1200    R= 81 C= 75 P=256
   H= 37 W= 30 MAX=*** D=FFFFFFFFFFF00000
   RF=8000800000000000 S=0000000000000000
   OPTS=FD923040A0000000 NCOLORS=  8
   Background color = WHITE
   Color 1 = BLACK
   Color 2 = GRAY22
   Color 3 = GRAY33
   Color 4 = GRAY44
   Color 5 = GRAY66
   Color 6 = GRAY88
   Color 7 = GRAYAA
   Color 8 = GRAYCC
   Ratio = 1.33333
   Hsize =     7.5
   Vsize =      10
   F=4

   NOTE: The PROCEDURE GTESTIT used 0:00:02.0 real 0:00:00.30 cpu.

For the PS driver, the default HSIZE is 7.5 inches. The default VSIZE is 10 inches. We are using the V3 template from the SASHELP.TEMPLT catalog, which produces three template panels of equal size, one above the other. For each panel, the V3 template uses 1/3 the vertical area and the entire horizontal area. Therefore, we need only reduce the VSIZE for the graphs to 1/3 of their default values. There is no need to change the value of the HSIZE option.

To avoid any confusion, clear all the graphs out of the WORK.GSEG catalog.

       proc greplay nofs igout=work.gseg;
    
          delete _all_;
        run;
        quit;
    
Next, create the PROC GCHART output using a value for VSIZE that is 1/3 of the default value for the PS driver.
    goptions reset=all target=ps ftext=swiss nodisplay hby=0
             vsize=3.3;
    
    proc gchart data=one gout=work.gseg;
    
       vbar player/ sumvar=rank;
    
       by position;
    
       pattern1 v=solid c=black;
       title1 'This is a graph for #byval(position)';
     run;
     quit;
    
Specify VSIZE=0 to reset the option to its default value. To ensure correct results, specify VPOS=0 to reset this option to its default value, too. You must do this before you invoke PROC GREPLAY so that the templated graph will use the entire graphics area.
    goptions vsize=0 vpos=0 display;
    
    proc greplay nofs igout=work.gseg tc=sashelp.templt 
                    template=v3;
    
       treplay 1:GCHART
               2:GCHART1
               3:GCHART2;
     run;
     quit;
    
The output from PROC GCHART is now properly proportioned. You can easily apply this method to other templates. For example, the L2R2 template (also found in the SASHELP.TEMPLT catalog), has 4 panels of equal size positioned as 2 panels on the left and 2 panels on the right. To proportion graphs for this template, simply reduce both the HSIZE and VSIZE values to half their default values.