Data visualization with SAS programming

how to set different row gutters within three-row lattice layout and align properly

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

how to set different row gutters within three-row lattice layout and align properly

I have been trying in many ways to set different row gutters within a three-row lattice layout. One of the possible ways is to have two layouts, one of which contains a two-row lattice layout and another contains the remaining one-row layout, embedded within a two-row lattice layout. Though this way is feasible, I cannot align properly in x-axis between the upper row1&2 and row3. I have tried to use columndatarange=union and autoalign=auto options in layout lattice statement however neither way works. I am stuck in this situation and any idea will be greatly appreciated!

 

for_post2.png

 


Accepted Solutions
Solution
‎10-22-2017 07:53 PM
SAS Super FREQ
Posts: 1,265

Re: how to set different row gutters within three-row lattice layout and align properly

Posted in reply to swimmingfish

The row gutter setting apply to all the rows in a Lattice.  We did not anticipate the need for a varying amount of gutter.  It would be interesting to understand the reason for this need.  Given what you are doing, you would have to set all the axis options in the same manner to get similar axis layout.

 

An alternative may be to use one outer Layout Lattice, with three independent Lattices (each having 2 columns).  Then potentially, you could use the OUTERPAD option on each inner Lattice to create a varying gutter.

 

Lattice_Varying_Gutter.png

 

 

proc template;
  define statgraph Varying_Gutters;
    begingraph;
	  layout lattice / columns=1 rows=3;
	    layout lattice / columns=2 rows=1  border=true rowdatarange=union;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	    layout lattice / columns=2 rows=1 outerpad=(top=10px) 
                             rowdatarange=union border=true;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	    layout lattice / columns=2 rows=1 outerpad=(top=20px) 
                             rowdatarange=union border=true;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	  endlayout;
    endgraph;
  end;
run;

proc sgrender template=varying_gutters data=sashelp.heart;
run;

View solution in original post


All Replies
Solution
‎10-22-2017 07:53 PM
SAS Super FREQ
Posts: 1,265

Re: how to set different row gutters within three-row lattice layout and align properly

Posted in reply to swimmingfish

The row gutter setting apply to all the rows in a Lattice.  We did not anticipate the need for a varying amount of gutter.  It would be interesting to understand the reason for this need.  Given what you are doing, you would have to set all the axis options in the same manner to get similar axis layout.

 

An alternative may be to use one outer Layout Lattice, with three independent Lattices (each having 2 columns).  Then potentially, you could use the OUTERPAD option on each inner Lattice to create a varying gutter.

 

Lattice_Varying_Gutter.png

 

 

proc template;
  define statgraph Varying_Gutters;
    begingraph;
	  layout lattice / columns=1 rows=3;
	    layout lattice / columns=2 rows=1  border=true rowdatarange=union;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	    layout lattice / columns=2 rows=1 outerpad=(top=10px) 
                             rowdatarange=union border=true;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	    layout lattice / columns=2 rows=1 outerpad=(top=20px) 
                             rowdatarange=union border=true;
		  rowaxes;
		    rowaxis;
		  endrowaxes;
		  scatterplot x=cholesterol y=systolic;
		  scatterplot x=cholesterol y=diastolic;
		endlayout;
	  endlayout;
    endgraph;
  end;
run;

proc sgrender template=varying_gutters data=sashelp.heart;
run;
New Contributor
Posts: 3

Re: how to set different row gutters within three-row lattice layout and align properly

Posted in reply to Sanjay_SAS

Thank you Sanjay for your quick and professional response! It is a great idea to include padding in this case. The only reason for setting different row gutters is to inset the vertical tick values between the second and third row. I was running the program in SAS 9.3 so the new feature of conveniently rotating tick values is not available. I used drawtext statement instead so there is a need to hold an extra space for the vertical tick values.

 

The problem is resolved and I truly appreciate your help!

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 118 views
  • 1 like
  • 2 in conversation