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;
> 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 */
I meant YELLOW....
LOL....
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;
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?
> 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 */
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.