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

Hi there, 

I just want to change the bar color in my GTL temple.

No group in my data, just want to show all bars in a same color, like the RED I specified here....
However, the bar color always black...

Anyone can help? Thanks!

 

proc template;
 define statgraph swimmer;
  begingraph / drawspace=datavalue;


  layout lattice / rows=1 columns=3 columnweights=(0.1 0.75 0.15) columngutter=0;

    layout overlay;
      entry textattrs=(color=white size=5) "blank";
    endlayout;

    layout overlay / walldisplay=none

        xaxisopts = (label="xxxxx"
                     labelattrs=(size=7)
                     tickvalueattrs=(size=7)
                     linearopts = (viewmin=0 viewmax=140
                                   tickvaluesequence = (start=0 end=140 increment=1)))


      yaxisopts = (label="xxxxxx"  
                     labelattrs=(size=7)
                     display=(label)
                     linearopts = (viewmin=1 viewmax=215
                                   tickvaluesequence = (start=1 end=215 increment=1)));


      barchart  x=obs y=dur /  orient=horizontal barwidth=0.1 fillattrs=(color=yellow);

        endlayout;

   
      layout overlay;
          entry textattrs=(color=white size=5) "blank";
        endlayout;   
    endlayout;
  endgraph;
  end;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

> Is there a way to remove the black outline of the bars?

barchart x=obs y=dur / display=(fill) ...;

 

If you truly want all those bars, then you need to make the plot taller (for orientation=horizontal) or wider (for orientation=vertical).  If you want a tall horizontal chart, use


ods graphics / width=640px height=1800px;  /* very tall */
proc sgrender data=A template=swimmer;
run;
ods graphics / width=640px height=480px; /* reset to standard dimensions */

View solution in original post

5 REPLIES 5
Coooooo_Lee
Obsidian | Level 7

I meant YELLOW....  

LOL....

Rick_SAS
SAS Super FREQ

You should always include data for your program.

 

Lots of issues here, but try these:
1. You are explicitly setting start=, end=, and increment= options. That will result in either 140 or 215 bars, depending on the orientation. When you plot that many bars on a standard-sized plot, the fill will be small and you will mostly see the black outline of the bars

2. You set barwidth=0.1, which makes the bars even thinner. Again, this causes the yellow fill to be tiny.

3. You are setting orient=horizontal, which means that the YAXISOPTS apply to the X variable and the XAXISOPTS apply to the Y variable, which can be confusing.

 

Try modifying this code until you get what you need:

proc template;
 define statgraph swimmer;
  begingraph / drawspace=datavalue;
  layout lattice / rows=1 columns=3 columnweights=(0.1 0.75 0.15) columngutter=0;
    layout overlay;
      entry textattrs=(color=white size=5) "blank";
    endlayout;

    layout overlay / walldisplay=none
        xaxisopts = (label="xxxxx"
                     labelattrs=(size=7)
                     tickvalueattrs=(size=7)
                     linearopts = (viewmin=0 viewmax=140
                                   tickvaluesequence = (start=0 end=140 increment=20)))

      yaxisopts = (label="yyyyy"  
                     labelattrs=(size=7)
                     /*display=(label)*/
                     linearopts = (viewmin=0 viewmax=215
                                   tickvaluesequence = (start=0 end=215 increment=25)));

      barchart  x=obs y=dur / /*orient=horizontal*/ barwidth=1 fillattrs=(color=yellow);
        endlayout;
   
      layout overlay;
          entry textattrs=(color=white size=5) "blank";
        endlayout;   
    endlayout;
  endgraph;
  end;
run;

data A;
input obs dur;
datalines;
20   100
40   127
60   165
80   154
100  121
120   92
140   16
;

proc sgrender data=A template=swimmer;
run;

 

Coooooo_Lee
Obsidian | Level 7

Hi Rick,

 

First thanks for sharing your idea. please see my replies below:

 

1. You are explicitly setting start=, end=, and increment= options. That will result in either 140 or 215 bars, depending on the orientation. When you plot that many bars on a standard-sized plot, the fill will be small and you will mostly see the black outline of the bars

 

The number here is based on my data, which is truly what I want.

 

2. You set barwidth=0.1, which makes the bars even thinner. Again, this causes the yellow fill to be tiny.

 

This is also what I want as there are too many bars need to be ploted here.

 

3. You are setting orient=horizontal, which means that the YAXISOPTS apply to the X variable and the XAXISOPTS apply to the Y variable, which can be confusing.

 

I do need to have a transposed barchart, this is also sepcified on purpose.

 

Is there a way to remove the black outline of the bars?

 

 

Rick_SAS
SAS Super FREQ

> Is there a way to remove the black outline of the bars?

barchart x=obs y=dur / display=(fill) ...;

 

If you truly want all those bars, then you need to make the plot taller (for orientation=horizontal) or wider (for orientation=vertical).  If you want a tall horizontal chart, use


ods graphics / width=640px height=1800px;  /* very tall */
proc sgrender data=A template=swimmer;
run;
ods graphics / width=640px height=480px; /* reset to standard dimensions */
Coooooo_Lee
Obsidian | Level 7
Thanks Rick

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1073 views
  • 0 likes
  • 2 in conversation