Sas 端点直方图
我正在尝试修改SAS proc sgplot中的直方图,以便箱子不会以图形方式居中于中点。相反,我希望它们是从0到5,5到10,等等。按照这个图目前的方式,我在0处得到一个奇怪的“半条”——它的厚度不合适,看起来很奇怪 我不喜欢使用sgplot,如果我仍然可以得到所需的叠加直方图,我可以使用单变量或proc模板。以下是我的数据:Sas 端点直方图,sas,histogram,Sas,Histogram,我正在尝试修改SAS proc sgplot中的直方图,以便箱子不会以图形方式居中于中点。相反,我希望它们是从0到5,5到10,等等。按照这个图目前的方式,我在0处得到一个奇怪的“半条”——它的厚度不合适,看起来很奇怪 我不喜欢使用sgplot,如果我仍然可以得到所需的叠加直方图,我可以使用单变量或proc模板。以下是我的数据: data have; input x y; cards; 1 . 5 . 6 . 20 . 13 . 4 . 2 . 2 . 7 . 4 .
data have;
input x y;
cards;
1 .
5 .
6 .
20 .
13 .
4 .
2 .
2 .
7 .
4 .
17 .
33 .
2 .
. 2
. 15
. 4
. 10
. 35
. 20
. 6
. 14
;
run;
proc sgplot data=have;
histogram x / fillattrs=graphdata1 name='s' legendlabel='x'
transparency=0.5 binstart=0 binwidth=5;
histogram y / fillattrs=graphdata2 name='d' legendlabel='y'
transparency=0.5 binstart=0 binwidth=5;
keylegend 's' 'd' / location=inside position=topright across=1;
xaxis display=(nolabel) label='label' min=0 max=40;
run;
谢谢
派尔
BINSTART参数是第一个bin的中点,而不是低端。你想让2.5成为中点,那么就这样定义它
GTL确实允许您以您想要的方式定义条形图,并且在以后的版本中,该选项可能位于SGPLOT中。请注意xvalues=leftpoints
,这是控制箱子结构的因素
proc template;
define statgraph myhist;
begingraph;
layout overlay/cycleattrs=true x2axisopts=(labelFitPolicy=Split) xaxisopts=( display=( ticks tickvalues line )
type=linear linearopts=( viewmin=0 viewmax=40 ) );
histogram x/binstart=0 binwidth=5 xvalues=leftpoints datatransparency=0.5 legendlabel='x'
name='x' fillattrs=graphdata1;
histogram y/binstart=0 binwidth=5 xvalues=leftpoints datatransparency=0.5 legendlabel='y'
name='y' fillattrs=graphdata2;
DiscreteLegend "x" "y"/ Location=Inside across=1 halign=right valign=top;
endlayout;
endgraph;
end;
quit;
proc sgrender template=myhist data=have;
run;
谢谢,乔。这正是我需要的。
proc template;
define statgraph myhist;
begingraph;
layout overlay/cycleattrs=true x2axisopts=(labelFitPolicy=Split) xaxisopts=( display=( ticks tickvalues line )
type=linear linearopts=( viewmin=0 viewmax=40 ) );
histogram x/binstart=0 binwidth=5 xvalues=leftpoints datatransparency=0.5 legendlabel='x'
name='x' fillattrs=graphdata1;
histogram y/binstart=0 binwidth=5 xvalues=leftpoints datatransparency=0.5 legendlabel='y'
name='y' fillattrs=graphdata2;
DiscreteLegend "x" "y"/ Location=Inside across=1 halign=right valign=top;
endlayout;
endgraph;
end;
quit;
proc sgrender template=myhist data=have;
run;