X-Axis Interruption in a Figure

From PHUSE Wiki
Jump to: navigation, search
SaschaAhrweiler 10:26, 31 January 2012 (CST)
Xaxis interuption.JPG

Description

Sometimes graphs have to be produced which require an interruption of the x-Axis in order to point out the non-uniformity of the axis' time interval.

This little example will show how this can easily be done with some AXIS statements and ANNOTATE.

Approach

There are multiple ways to solve this issue. One easy solution is the following:

  • Don't draw the x-axis by setting the axis specifications in PROC GPLOT, that means in the axis specification for the X-Axis it is necessary to specify STYLE=0.
  • Use ANNOTATE to draw the axis line with the interruption and the “//”

Example for Program Specifications

In this example the x-axis has a range of 0 to 7 and it has to be interrupted at 0.5 (between first and second tick mark).

Axis Specifications

The axis specifications should be:

axis1 order =  0 to 7 by 1 
  label=( h=0.75 '' )
  value = (h=0.75  T=1 j=c 'Baseline' 
                   T=2 j=c 'Week 1'
                   T=3 j=c 'Week 2'
                   T=4 j=c 'Start of' j=c 'Maintenance'
                   T=5 j=c 'Month 3'
                   T=6 j=c 'Month 6'
                   T=7 j=c 'Month 9'
                   T=8 j=c 'End of' j=c 'Maintenance' ) 
           offset = (0.6 cm , 0.7 cm)
           major = none
           minor = none
           style=0;

Note that the style=0 will suppress the drawing of the x-Axis;

Annotate Specifications

The following annotate specifications will draw the x-axis with the interruption and the "//":

data anno;
	length text $40;
	
	xsys="2"; * System for x-axis: values;
	ysys="1"; * System for y-axis: percent;
	---

/* interruption of x-axis*/

	function='move';* Move ‘Pencil’ to value=0 at x-axis and percent=0 at y-axis;
	x=0; y=0;
	output;
	function='draw';* Draw line to value=0.46 at x-axis and percent=0 at y-axis;
	x=0.46;  
	line=1;
	output;

	y=1; x=0.50;*Write “/” at value 0.50 at x-axis and percent=1 with the text positioned ;
	function='label';*as specified in position;
	text='/';
        position='4';
	output;
	 
	position='6';* Write “/” at the same coordinates but with different specified position;
	output;

	y=0;
	function='move';* Move ‘pencil’ to value=0.54 at x-axis and percent=0 at y-axis;
	x=0.54;
	output;
	function='draw';* Draw line to value=7 at x-axis and percent=0 at y-axis;
	x=7;
	output;
                               *The following steps are necessary if OFFSET is specified in axis statement;
	xsys='1';* system for x-Axis changed to: percent;
	function='move';
	x=0; y=0;* Move ‘pencil’ to percent=0 at x- and y-axis;
	output;
	function='draw';* Draw line to 5 percent at x-axis and 0 percent at y-axis;
	x=5;  
	output;

       function='move';* Move ‘pencil’ to 95 percent at x-axis and 0 percent at y-axis;
	x=95;  
	output;
	function='draw';* Draw line to 100 percent at x-axis and 0 percent at y-axis;
	x=100;  
	output;
run;