Data visualization with SAS programming

Problem in setting Legend Background Color:SGPLOT

Reply
Occasional Contributor
Posts: 17

Problem in setting Legend Background Color:SGPLOT

Hi,

I need a solution to set Background color YELLOW on SGPLOT:

-I am using SAS 9.2 and creating PNG.

-However,I have tried to solve it via PROC TEMPLATE but it not working?

   proc template;

     define style styles.default ;

     parent = styles.Journal;

     style GraphLegendBackground / color=Yellow;

     style GraphFonts /   

     'GraphDataFont' =("Arial",10pt)

     'GraphUnicodeFont' = ("Arial",6.5pt)

     'GraphValueFont'=("Arial",7.0pt,bold)

     'GraphLabelFont'=("Arial",8.2pt,bold)

     'GraphFootnoteFont' = ("Arial",8pt)

     'GraphTitleFont' = ("Arial",10pt,bold)

     'GraphAnnoFont' = ("Arial",10pt);

     end;

   run;

-But not changing LEGEND Background Color, all other stuffs are okay from that figures.

Thanks in advance

SAS Super FREQ
Posts: 925

Re: Problem in setting Legend Background Color:SGPLOT

It looks like your creating a circular dependency. Normally, the JOURNAL style inherits from DEFAULT, but here you have overridden DEFAULT and inherited from JOURNAL. Try this instead:

  proc template;

     define style styles.myjournal ;  /* different name */

     parent = styles.Journal;

     style GraphLegendBackground / color=Yellow;

     style GraphFonts /  

     'GraphDataFont' =("Arial",10pt)

     'GraphUnicodeFont' = ("Arial",6.5pt)

     'GraphValueFont'=("Arial",7.0pt,bold)

     'GraphLabelFont'=("Arial",8.2pt,bold)

     'GraphFootnoteFont' = ("Arial",8pt)

     'GraphTitleFont' = ("Arial",10pt,bold)

     'GraphAnnoFont' = ("Arial",10pt);

     end;

   run;

ods pdf file="output.pdf" style=myjournal; /* or whatever ODS destination you are using */

< your program >

ods pdf close;

Hope this helps!

Dan

Occasional Contributor
Posts: 17

Re: Problem in setting Legend Background Color:SGPLOT

It not worked on after using on:

ODS LISTING GPATH="XX" style=myjournal;

ODS LISTING CLOSE

SAS Super FREQ
Posts: 1,134

Re: Problem in setting Legend Background Color:SGPLOT

It is worth pausing to consider if this is a good idea.  Color perception is not absolute, but relative to the background.  We know that a gray color swatch in black background looks white, and the same gray color in a white background looks black.  We intentionally use the same background color as the "Wall" color for the legend, so the colors used in the graph are seen against the same background in the legend.  Changing the legend background color to something different from the wall color could have an adverse impact on the perception of the colors.

Ask a Question
Discussion stats
  • 3 replies
  • 597 views
  • 0 likes
  • 3 in conversation