Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Bill3
Fluorite | Level 6

Are there any parameter similar to the Makercharacterposition about scatterplot setp.

I want to adjust the trianglerightfilled position.

scatterplot x= y= / markerattrs=(symbol=trianglerightfilled)

1 ACCEPTED SOLUTION

Accepted Solutions
MarciaS
SAS Employee

You can use the DISCRETEOFFSET= option on the SCATTERPLOT statement to make small adjustments to the position of the marker symbol IF your axis is a discrete type axis. 

 

If your axis is not a discrete type axis, one method to add symbols on your graph with adjusted position is to place the symbol using the MARKERCHARACTER= option on the SCATTERPLOT statement.

 

To to this, you would create a variable in your data set to use in the MARKERCHARACTER= option and specify the MARKERCHARACTERPOSITION= option to adjust the position of the symbol. 

 

To see the desired symbol, you would define a format with PROC FORMAT that uses the unicode function with the 4 digit hex value for the unicode symbol you want to see and associate the format with the MARKERCHARACTER= variable.

Note that the format value must be expressed  using the default ODS escape sequence (*ESC*) preceeding the unicode function with hex value for the unicode symbol. Additionally, the MARKERCHARACTERATTRS= option might be necessary to reference a format that supports the unicode character you want to place on the graph. 

 

The following sample demonstrates how to do this. 

 

data sample;    
  label="trianglerightfilled";
  do x=1 to 5;
	  output;
  end;
run;
proc format;
  value $ myfmt
	  'trianglerightfilled'="(*ESC*){unicode '25b6'x}";
run;
ods path(prepend) work.templat(update);
proc template;
  define statgraph plot;
	  begingraph;
		  layout overlay;
			  scatterplot x=x y=x / markercharacter=label labelstrip=true 
				  markercharacterattrs=(family='Arial Unicode MS' size=14pt)
          markercharacterposition=topright;
 			endlayout;
		endgraph;
	end;
run;
proc sgrender data=sample template=plot;
  format label $myfmt.;
run;

Hope this helps.

 

View solution in original post

6 REPLIES 6
ballardw
Super User

Are you asking "is there another option other than Markercharacterposition"?

 

What sort of adjustment do you want?

Jitter=Auto will apply small differences to position controlled with options in the JITTEROPTS=(jitter-options) settings. Not going to list all the possibilities, read the online help for SCATTERPLOT.

 

With any question it is a good idea to include the entire code you have not just one line. That way we can avoid suggesting an option that may not be compatible with other options you are using or may allow other alternatives.

There are so many possible interactions/limitations with the graphic options this goes double for them.

MarciaS
SAS Employee

You can use the DISCRETEOFFSET= option on the SCATTERPLOT statement to make small adjustments to the position of the marker symbol IF your axis is a discrete type axis. 

 

If your axis is not a discrete type axis, one method to add symbols on your graph with adjusted position is to place the symbol using the MARKERCHARACTER= option on the SCATTERPLOT statement.

 

To to this, you would create a variable in your data set to use in the MARKERCHARACTER= option and specify the MARKERCHARACTERPOSITION= option to adjust the position of the symbol. 

 

To see the desired symbol, you would define a format with PROC FORMAT that uses the unicode function with the 4 digit hex value for the unicode symbol you want to see and associate the format with the MARKERCHARACTER= variable.

Note that the format value must be expressed  using the default ODS escape sequence (*ESC*) preceeding the unicode function with hex value for the unicode symbol. Additionally, the MARKERCHARACTERATTRS= option might be necessary to reference a format that supports the unicode character you want to place on the graph. 

 

The following sample demonstrates how to do this. 

 

data sample;    
  label="trianglerightfilled";
  do x=1 to 5;
	  output;
  end;
run;
proc format;
  value $ myfmt
	  'trianglerightfilled'="(*ESC*){unicode '25b6'x}";
run;
ods path(prepend) work.templat(update);
proc template;
  define statgraph plot;
	  begingraph;
		  layout overlay;
			  scatterplot x=x y=x / markercharacter=label labelstrip=true 
				  markercharacterattrs=(family='Arial Unicode MS' size=14pt)
          markercharacterposition=topright;
 			endlayout;
		endgraph;
	end;
run;
proc sgrender data=sample template=plot;
  format label $myfmt.;
run;

Hope this helps.

 

DanH_sas
SAS Super FREQ

Sorry @MarciaS , I missed that you referred to this same trick in your post.

Bill3
Fluorite | Level 6
labelstrip=true ,markercharacterattrs=(family='Arial Unicode MS' size=14pt)
It's right in my code, thank you very much!
DanH_sas
SAS Super FREQ

You can do it by defining a new symbol, referring to a "right triangle" glyph in a full-featured Unicode font (such as "Arial Unicode MS"). You can use the HOFFSET / VOFFSET options to move it from center. In the example below, I added a "centered", circle-filled scatter plot as a reference.

 

proc sgplot data=sashelp.class noautolegend;
symbolchar name=rt char='25B6'x /
            textattrs=(family="Arial Unicode MS") hoffset=0.2;
scatter x=weight y=height / markerattrs=(symbol=circlefilled);
scatter x=weight y=height / markerattrs=(symbol=rt size=30);
run;
Bill3
Fluorite | Level 6
Thank you for your "Arial Unicode MS".

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1105 views
  • 8 likes
  • 4 in conversation