BookmarkSubscribeRSS Feed
ttmei
Fluorite | Level 6

Hi, 

 

I tried to add curvelabels to several regression lines. As mentioned above, I used "regressionplot" and "group=" option. The "group=" option conflicted with the "curvelabel=" option. I may also nested "drawtext" in the layout overlay. But if I want to change the size of the figure, the nested "drawtext" will not automaticly fit the size. Is there a better way to fix this problem?

 

Regards,

ttmei

 

My code:

proc template; 
	define statgraph ttmei; 

		begingraph /designwidth=700px designheight=300px border=false; 

			      discreteattrmap name="scatter1" /ignorecase=true;
				  	 value "600-650" / markerattrs=(symbol=circle  size=8 color=blue) lineattrs=(thickness=2 color=blue);
				  	 value "650-700" / markerattrs=(symbol=circle size=8  color=cxff00ff) lineattrs=(thickness=2 color=cxff00ff);
				  	 value "700-750" / markerattrs=(symbol=circle  size=8 color=orange) lineattrs=(thickness=2 color=orange);
				  	 value "750-800" / markerattrs=(symbol=circle size=8  color=green) lineattrs=(thickness=2 color=green) ;
				  	 value "800-850" / markerattrs=(symbol=circle size=8  color=black) lineattrs=(thickness=2 color=black) ;
				  	 value "850-900" / markerattrs=(symbol=circle size=8  color=brown) lineattrs=(thickness=2 color=brown) ;
				  	 value "900-950" / markerattrs=(symbol=circle size=8  color=yellow) lineattrs=(thickness=2 color=yellow) ;
				  	 value "950-1000" / markerattrs=(symbol=circle size=8  color=red) lineattrs=(thickness=2 color=red) ;
				  	 value "1000-1100" / markerattrs=(symbol=circle size=8  color=purple) lineattrs=(thickness=2 color=purple) ;
				  	 value "1100-1300" / markerattrs=(symbol=circle size=8  color=darkgreen) lineattrs=(thickness=2 color=darkgreen) ;
			      discreteattrvar attrvar=scatter var=dor attrmap="scatter1";

			layout lattice /rows=1 columns=2;

				layout overlay/
					yaxisopts=(display=(ticks tickvalues line) offsetmin=0.1 offsetmax=0 tickvalueattrs=(FAMILY="Arial" SIZE=10pt)
							linearopts=(viewmin= 0 viewmax=0.6 thresholdmin=0) labelattrs=(FAMILY="Arial" SIZE=10pt))
					xaxisopts=(display=(ticks tickvalues line) offsetmin=0 offsetmax=0 tickvalueattrs=(FAMILY="Arial" SIZE=10pt)
							linearopts=(viewmin= 0 viewmax=1 thresholdmin=0) labelattrs=(FAMILY="Arial" SIZE=10pt)); 
					scatterplot  y=kx x=Mf/group=scatter name="dot1"; 
					regressionplot y=kx x=Mf/group=scatter  name="line1";
/*					mergedlegend "dot1" "line1"/title="Dry density" exclude=( "500-600" "1400-1700" ".") location=inside border=false across=2 halign=right valign=bottom*/
/*													valueattrs=(size=10);	*/
					entry halign=left "(A)"/location=inside valign=top textattrs=(family="Arial" size=10pt) ;	
				 endlayout; 

				layout overlay/
					yaxisopts=(display=(ticks tickvalues line label) label="Tc/Dd" offsetmin=0 offsetmax=0 tickvalueattrs=(FAMILY="Arial" SIZE=10pt)
							linearopts=(viewmin= 0.2 viewmax=0.8 thresholdmin=0) labelattrs=(FAMILY="Arial" SIZE=10pt))
					xaxisopts=(display=(ticks tickvalues line) offsetmin=0 offsetmax=0 tickvalueattrs=(FAMILY="Arial" SIZE=10pt)
							linearopts=(viewmin= 0 viewmax=1 thresholdmin=0) labelattrs=(FAMILY="Arial" SIZE=10pt)); 
					scatterplot x=mf y=cd/ markerattrs=(symbol=circle size=8 color=black);
					regressionplot x=mf y=cd/lineattrs=(thickness=2 color=black) ;
					entry halign=left "(B)"/location=inside valign=top textattrs=(family="Arial" size=10pt) ;	
					layout gridded/columns=1 rows=2 location=inside halign=right valign=bottom;
		                 entry  halign=right "Y=0.32X+0.31"/
								textattrs=(family="Arial" size=10pt);
		                 entry  halign=right "R"{sup '2'}"=0.99; P<0.05"/
								textattrs=(family="Arial" size=10pt);
				    endlayout;
				 endlayout; 

		       rowheaders;
		                 entry "Tc (W m" {sup '-1'} " K" {sup '-1'}")" /rotate=90 textattrs=(family="Arial" size=10pt);
		       endrowheaders;

		        sidebar / align=bottom;
			        entry halign=center "Wc (g g"{sup '-1'}")"/valign=bottom location=outside
			              textattrs=(FAMILY="Arial" SIZE=10pt) pad=(bottom=8px);
		        endsidebar;

			endlayout; 
		endgraph; 
	end; 
run; 
ods  html image_dpi=300  ;
proc sgrender data=tcmax.tc template="ttmei" ; 
run; 

 

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I had a quick search on the blog for graphs:

http://blogs.sas.com/content/graphicallyspeaking/?s=curvelabels

There is a tag at the bottom for full code examples.  They are SGPLOT, however with the tmplout= option on proc sgplot you can see the underlying template code generated (I find that is a quick way to find syntax).  Would markerchar work? 

ttmei
Fluorite | Level 6

Thank you for your reply. I have tried "markerchar" and it's not work in regressionplot. Sorry. 

 

Regards,

ttmei

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, I don't understand "its not work in regression", do you mean its not an optin for that type of graph?  If so then just add a scatter over the reg plot with options you need, and set the scattter to have very small points so they don't show.  That is a basic concept of GTL is that you overlay various graphs with various options to get output you want, one statement is generally not going to do everything.

For instance, you could pull reg values out from a proc reg step, then use that data to plot an scatter.

proc reg...;

  model...;

  ods output ParameterEsitmates=pe...;

run;

proc sgplot...

ttmei
Fluorite | Level 6

Yes, I think add a scatter on the reg line is a good idea. Should work. Thank you.

ballardw
Super User

Which version of SAS are you running. There have been notable enhancements for graphics options in the last couple of releases.

Jay54
Meteorite | Level 14

It would help if you add the full program with data to see what you are getting and what you want.  it also helps to know what SAS release you have.  

 

That said, CURVELABEL=string is used to put a string curve label for non-grouped case.  If you want to label each regression curve by the group value, I suggest you use an overlaid SCATTERPLOT that has only the the point you want (maybe last) with a DATALABEL=column to display the group values.  You can set the markersize for the scatter to zero.  With SAS 9.4M3, you can also use TEXTPLOT.

ttmei
Fluorite | Level 6

Thank you for your suggestions! Unfortunately my SAS version is 9.4 1M2. But I will try  SCATTERPLOT to display the label of the last point value. This should work. Thank you again.

 

ttmei
Fluorite | Level 6

Hi, 

 I'm using SAS 9.4 1M2.

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
  • 8 replies
  • 2107 views
  • 2 likes
  • 4 in conversation