BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
swimmingfish
Calcite | Level 5

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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

2 REPLIES 2
Jay54
Meteorite | Level 14

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;
swimmingfish
Calcite | Level 5

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!

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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