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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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