BookmarkSubscribeRSS Feed
KaraG
Fluorite | Level 6

I have a lattice with three rows, plus a legend at the bottom in a sidebar statement. My problem is that the plot widths for each of the three rows is not even -- the bottom one is shorter than the first two (because of the bottom sidebar statement? because it is the only row with a label and tick values?) -- how do I make the three rows the same width? 

 

Here is the code: 

proc template; 
define statgraph sgdesign; 
begingraph / border=false attrpriority=none designheight=8in designwidth=3.5in
datacontrastcolors=(black CX2d69b9 rose vpav); 
layout lattice / rows=3 rowdatarange=union rowweights=uniform; 
rowaxes; 
rowaxis / display=(ticks tickvalues line) linearopts=(viewmin=40 viewmax=80) tickvalueattrs=(size=11 color=charcoal) ; 
rowaxis / display=(ticks tickvalues line) linearopts=(viewmin=115 viewmax=180) tickvalueattrs=(size=11 color=charcoal);
rowaxis / display=(ticks tickvalues line) linearopts=(viewmin=242 viewmax=275) tickvalueattrs=(size=11 color=charcoal); 
endrowaxes;
layout overlay / xaxisopts=(linearopts=(viewmin=15 viewmax=25 tickvaluelist=(15 17 19 21 23 25)) display=(ticks line)) yaxisopts=(linearopts=(viewmin=5000 viewmax=30000) display=(ticks tickvalues line)); 
seriesplot x=time_years y=biomasswoody_15_1000kgha / group=treatment lineattrs=(thickness=2) name="graph" ; 
entry halign=left 'Young' / valign=top textattrs=(weight=bold size=12);
referenceline x=19 ; 
referenceline x=23 ; 
endlayout; 
layout overlay / xaxisopts=(linearopts=(viewmin=40 viewmax=50 tickvaluelist=(40 42 44 46 48 50)) display=(ticks line)) yaxisopts=(linearopts=(viewmin=5000 viewmax=30000) display=(ticks tickvalues line)); 
seriesplot x=time_years y=biomasswoody_40_1000kgha / group=treatment lineattrs=(thickness=2);
entry halign=left 'Successional' / valign=top textattrs=(weight=bold size=12);
referenceline x=44 ;
referenceline x=48;
endlayout; 
layout overlay / xaxisopts=(linearopts=(viewmin=100 viewmax=110 tickvaluelist=(100 102 104 106 108 110) tickdisplaylist=("0" "2" "4" "6" "8" "10")) display=(ticks line tickvalues label) tickvalueattrs=(size=11 color=charcoal) label="Years since treatment" labelattrs=(size=14)) yaxisopts=(linearopts=(viewmin=5000 viewmax=30000) display=(ticks tickvalues line)); 
seriesplot x=time_years y=biomasswoody_100_1000kgha / group=treatment lineattrs=(thickness=2); 
entry halign=left 'Mature' / valign=top textattrs=(weight=bold size=12);
referenceline x=104;
referenceline x=108;
endlayout; 
sidebar / align=left ;
      entry "Woody biomass (100 kg ha(*ESC*){unicode '207b'x}(*ESC*){unicode '00b9'x})" / textattrs=(size=14 family="graphunicodetext") rotate=90 ;
  endsidebar;
sidebar / align=bottom; 
discretelegend "graph" / valueattrs=(size=10 color=charcoal) title="Treatment" titleattrs=(size=10 weight=bold color=charcoal) ; 
endsidebar;
endlayout; 
endgraph; 
end; 
run; 
proc sgrender data=MEL template=sgdesign; 
run; 

and then here is what I get: 

 

KaraG_0-1721762162786.png

 

Thank you!

4 REPLIES 4
ballardw
Super User

Have you tried ROWDATARANGE=UNIONALL ?

Or setting the viewmax/ viewmin pairs so that the max - min is the same for each?

 

I can't test whether that would have the desired result because you did not provide an example data set to plot.

KaraG
Fluorite | Level 6

Thanks for the reply. If I union the axes, the individual panels are no longer lined up correctly (they are showing different ranges within the dataset even though they look aligned in the resulting figure - hence the different view min/max for each panel). 

 

For now at least, I may have found a workaround by setting the row weights to make each panel take up the same amount of space. 

DanH_sas
SAS Super FREQ

Two things:

1. Set COLUMNDATARANGE=UNION to unify the column (X) axis ranges.

2. Create a single external COLUMNAXIS like you did for each of the ROWAXES. The X axis you see in the last cell is part of the cell space, causing your data space to be smaller. By making it external, all of the cells should have the same spacing.

 

Hope this helps!

KaraG
Fluorite | Level 6

Thanks for the reply. That didn't work for me because the x-axis needs to show a different data range for each panel (even though it looks like they are all the same in the figure). If I union the axes, the individual panels are no longer lined up correctly. I think since I have x axis options set in each panel, I am unable to also have the external x axis (?) 

 

For now at least, I may have found a workaround by setting the row weights to make each panel take up the same amount of space. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 438 views
  • 0 likes
  • 3 in conversation