Data visualization with SAS programming

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Reply
Occasional Contributor
Posts: 13

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Using Proc sgplot, and having some numbers needed to be subscript.

Tried to use

ODS escpechar='^";   and move options, but they did not work.

Data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H2O";

yaxis label ="(NH3)2SO4";

run;

Esteemed Advisor
Posts: 6,917

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Occasional Contributor
Posts: 13

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Thanks, I tried the following code, the output was not correct.

Data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

ODS escapechar='^';

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H^{unicode '2082'x}O";

yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

Results Preference.pngoutput.png

SAS Super FREQ
Posts: 864

Re: Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

The reason you're seeing the boxes is that the font you're using does not support enough of the Unicode specification to include all of the superscipt and subscript values. The example referenced by Art contained a little piece of code similar to the one below:


proc template;                                                                                                                         
   define style style.unifonts;                                                                                                               
   parent=Styles.Listing; /* or your favorite style */  
   style Graphfonts from GraphFonts /                                                                                                                  
   'GraphValueFont' = ("Monotype San WT  J",12pt)                                                                                            
      'GraphLabelFont' = ("Monotype San WT J",14pt)
      'GraphDataFont' = ("Monotype San WT J",12pt)
      'GraphTitleFont' = ("Monotype San WT J",12pt);                                                                                           
   end;                   
run;

If you set this style as your ODS style, then you're boxes will be filled! :-)

ods listing style=unifonts;

data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

ods escapechar='^';

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H^{unicode '2082'x}O";

yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

Hope this helps,

Dan

Occasional Contributor
Posts: 13

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Thanks Dan!

the HTML Type output was not correct.

The PNG Type output was correct.

Normally I copy the figure from HTML  Type, because it looks very neat.

html.pngPng.png

Esteemed Advisor
Posts: 6,917

Proc sgplot: how subscipt and superscript xaxis and yaxis (such H2O)?

Seemed to work ok for me.  Did I miss something?  The code I used was:

Data test;

  input x y;

  datalines;

1 2

3 6

7 10

8 19

;

proc template;                                                                                                                         

   define style unifonts;                                                                                                               

   parent=Styles.Default;  

   style Graphfonts from GraphFonts /                                                                                                                  

      'GraphValueFont' = ("Monotype San WT J",12pt)                                                                                            

      'GraphLabelFont' = ("Monotype San WT J",14pt)

      'GraphDataFont' = ("Monotype San WT J",12pt)

      'GraphTitleFont' = ("Monotype San WT J",12pt);                                                                                           

   end;                   

run; 

ods escapechar='^';

ods listing close;

ods html file='subsuper.html' path='c:\art' style=unifonts;

ods graphics / reset width=600px height=400px imagename='SubSuper' imagefmt=gif;

title 'Using Subscripts and Superscripts';

proc sgplot data=test;

   scatter x=x y=y;

   xaxis label="H^{unicode '2082'x}O";

   yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

ods html close;

ods listing;

Post a Question
Discussion Stats
  • 5 replies
  • 1630 views
  • 6 likes
  • 3 in conversation