Data visualization with SAS programming

X axis color different in SAS output and PNG output

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

X axis color different in SAS output and PNG output

Good morning,

I'm having a problem that the X axis color is not as defined in PNG output. As you can see in the attachments,  the X axis color is grey in the SAS output which is the color I want, but in the PNG output it is still black. Could someone help me with it? Thanks.

 

Here is my code:

data anno;
drawspace = 'GraphPercent';
function = 'Rectangle';
cornerradius=0.1;
linestyleelement='GraphAxisLines';
TRANSPARENCY=0.5;
Border=NOborder;
retain x1 y1 50 height width 100 widthunit 'Percent';
run;

ods graphics on/reset IMAGENAME ="&sheet.."
IMAGEFMT =PNG
width=8in height=2in;
goptions device=png gsfname=graphout;

PROC SGPLOT DATA = T1&sheet. sganno=anno dattrmap=attrmap noborder;
Scatter Y=NAME X = MY2R/markerAttrs=(size=6mM) group=MY2 attrid=MY2 datalabel=MY2R DATALABELATTRS=(size=8.5pt Family=ArialNarrow weight=bold COLOR=White) DATALABELPOS=CENTER transparency=0.1;
XAXIS DISPLAY=(NOTICKS) TICKVALUEFORMAT=data VALUEATTRS=(color=grey) label=' ';
YAXIS DISPLAY=(NOTICKS noline) LABEL = ' ' labelattrs=(color=White) valueattrs=(size=12pt Family=Arial color=black) GRID gridattrs=(color=WhiteSmoke) MINORGRIDATTRS=(color=green pattern=longdash thickness=2);
keylegend 'Percent'/noborder;
title "&sheet.";
run;


Accepted Solutions
Solution
‎01-17-2018 10:48 AM
SAS Super FREQ
Posts: 806

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

As far as I know the color of an axis line can only be changed using a style.

 

Here is an example of creating your own style and change the color, I have used red for better visability.

 

/* add my own itemsore in front of the ods path */
ods path
  (prepend) work.mytemplates (update)
;

/* show source of defualt style */
proc template;
  source styles.default;
run;

/* build my own style, only changing the color  */
proc template;
  define style styles.greyLine;
    parent=styles.htmlblue;

    class GraphAxisLines /
      contrastcolor = red
      color = red
    ;
    class GraphValueText /
      color = red
    ;
  end;
run;

ods html file="c:\temp\sample.html" gpath="c:\temp" style=styles.greyline;
proc sgplot data = sashelp.class tmplout="c:\temp\sgplot.sas" noborder;

  scatter x=age y=height;
  xaxis display=(noticks) tickvalueformat=data  label=' ';

run;
ods html close;

Maybe you can also use the REFLINE statement to add additional lines, you can control the color of each reference line.

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,046

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

Try removing the GOPTIONS statement. Normally, GOPTIONs should not be used with the ODS Graphics system. Let me know if that makes a difference.

 

Thanks!

Dan

Occasional Contributor
Posts: 16

Re: X axis color different in SAS output and PNG output

Thanks Dan, I removed the "goptions device=png gsfname=graphout;" but it is still did not work.

SAS Super FREQ
Posts: 806

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

Do you want to control the color of xaxis line or the color of the xaxis thick mark values?

Occasional Contributor
Posts: 16

Re: X axis color different in SAS output and PNG output

Posted in reply to Bruno_SAS

Hi Bruno, I want to control both of them and both color should be grey. 

SAS Super FREQ
Posts: 1,046

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

What ODS destinations do you have open? I cannot tell by your code.

SAS Super FREQ
Posts: 1,046

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

What ODS destinations do you have open? I cannot tell by your code.

Solution
‎01-17-2018 10:48 AM
SAS Super FREQ
Posts: 806

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

As far as I know the color of an axis line can only be changed using a style.

 

Here is an example of creating your own style and change the color, I have used red for better visability.

 

/* add my own itemsore in front of the ods path */
ods path
  (prepend) work.mytemplates (update)
;

/* show source of defualt style */
proc template;
  source styles.default;
run;

/* build my own style, only changing the color  */
proc template;
  define style styles.greyLine;
    parent=styles.htmlblue;

    class GraphAxisLines /
      contrastcolor = red
      color = red
    ;
    class GraphValueText /
      color = red
    ;
  end;
run;

ods html file="c:\temp\sample.html" gpath="c:\temp" style=styles.greyline;
proc sgplot data = sashelp.class tmplout="c:\temp\sgplot.sas" noborder;

  scatter x=age y=height;
  xaxis display=(noticks) tickvalueformat=data  label=' ';

run;
ods html close;

Maybe you can also use the REFLINE statement to add additional lines, you can control the color of each reference line.

Occasional Contributor
Posts: 16

Re: X axis color different in SAS output and PNG output

Posted in reply to Bruno_SAS

Thanks Bruno, it works!

Super User
Posts: 13,034

Re: X axis color different in SAS output and PNG output

Posted in reply to hanyi0221

If you send output to a different ODS destination and do not specify the same style then you likely get different results as HTML, RTF and PDF destinations by default use different ODS STYLES.

 

Change the path information in the code below and examine the differences between the 4 output files:

ods rtf file="c:\path\demo.rtf" ;
ods pdf file="c:\path\demo.pdf" ;

PROC SGPLOT DATA = T1&sheet. sganno=anno dattrmap=attrmap noborder;
Scatter Y=NAME X = MY2R/markerAttrs=(size=6mM) group=MY2 attrid=MY2 datalabel=MY2R DATALABELATTRS=(size=8.5pt Family=ArialNarrow weight=bold COLOR=White) DATALABELPOS=CENTER transparency=0.1;
XAXIS DISPLAY=(NOTICKS) TICKVALUEFORMAT=data VALUEATTRS=(color=grey) label=' ';
YAXIS DISPLAY=(NOTICKS noline) LABEL = ' ' labelattrs=(color=White) valueattrs=(size=12pt Family=Arial color=black) GRID gridattrs=(color=WhiteSmoke) MINORGRIDATTRS=(color=green pattern=longdash thickness=2);
keylegend 'Percent'/noborder;
title "&sheet.";
run;

ods pdf close;
ods rtf close;

ods rtf file="c:\path\demo2.rtf" style=meadow;
ods pdf file="c:\path\demo2.pdf"  style=meadow;

PROC SGPLOT DATA = T1&sheet. sganno=anno dattrmap=attrmap noborder;
Scatter Y=NAME X = MY2R/markerAttrs=(size=6mM) group=MY2 attrid=MY2 datalabel=MY2R DATALABELATTRS=(size=8.5pt Family=ArialNarrow weight=bold COLOR=White) DATALABELPOS=CENTER transparency=0.1;
XAXIS DISPLAY=(NOTICKS) TICKVALUEFORMAT=data VALUEATTRS=(color=grey) label=' ';
YAXIS DISPLAY=(NOTICKS noline) LABEL = ' ' labelattrs=(color=White) valueattrs=(size=12pt Family=Arial color=black) GRID gridattrs=(color=WhiteSmoke) MINORGRIDATTRS=(color=green pattern=longdash thickness=2);
keylegend 'Percent'/noborder;
title "&sheet.";
run;

ods pdf close;
ods rtf close;
Occasional Contributor
Posts: 16

Re: X axis color different in SAS output and PNG output

Hi Ballard, 

Thanks for your help. The meadow style did not make grey color but it did change the X axis color. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 181 views
  • 1 like
  • 4 in conversation