BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hanyi0221
Fluorite | Level 6

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;

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

10 REPLIES 10
DanH_sas
SAS Super FREQ

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

hanyi0221
Fluorite | Level 6

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

BrunoMueller
SAS Super FREQ

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

hanyi0221
Fluorite | Level 6

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

DanH_sas
SAS Super FREQ

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

DanH_sas
SAS Super FREQ

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

BrunoMueller
SAS Super FREQ

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.

hanyi0221
Fluorite | Level 6

Thanks Bruno, it works!

ballardw
Super User

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;
hanyi0221
Fluorite | Level 6

Hi Ballard, 

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 10 replies
  • 4368 views
  • 1 like
  • 4 in conversation