首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在SAS SGPLOT图中旋转x轴标签,使它们垂直(在90度至x轴)

如何在SAS SGPLOT图中旋转x轴标签,使它们垂直(在90度至x轴)
EN

Stack Overflow用户
提问于 2015-04-21 04:55:47
回答 2查看 7K关注 0票数 1

是否有可能在SAS SGPLOT中旋转x轴标签,使它们垂直(在90度至x轴)?适配选项旋转45度,但这不是我所需要的。

SAS代码:

代码语言:javascript
运行
复制
ods pdf style = custom file='';
proc sgplot data = filename;
series x = date y = unemployment_rate_15_24 / lineattrs = (color = CX963634 thickness = 2 pattern=solid);
series x = date y = unemployment_rate_15_ / lineattrs = (color = CX538DD5 thickness = 2 pattern=solid);
xaxis type=time fitpolicy=rotatethin notimesplit interval=year offsetmax=0 label = ' ' values = ("28FEB1995"d to "28FEB2015"d by year);
yaxis label = ' ' values = (0 to 18 by 2);
x2axis display=(nolabel novalues);
keylegend / location = inside position = topright;
label unemployment_rate_15_24 = "Youth (15-24 years) unemployment rate";
label unemployment_rate_15_ = "Overall (15+ years) unemployment rate";
run;
ods pdf close;

我还尝试在SAS中使用图形模板语言。下面是用GTL编写的等价物代码:

代码语言:javascript
运行
复制
proc template;
define statgraph mysgplot;
begingraph;
layout overlay /
cycleattrs=true 
xaxisopts=(label=" " offsetmax=0 type=time timeopts=(tickvaluelist=(12842 13207 13573 13938 14303 14668 15034 15399 15764 16129 16495 16860 17225 17590 17956 18321 18686 19051 19417 19782 20147) viewmin=12842 viewmax=20147 tickvaluefitpolicy=rotatethin splittickvalue=false interval=year)) 
yaxisopts=(label=" " type=linear linearopts=(tickvaluelist=(0 2 4 6 8 10 12 14 16 18) viewmin=0 viewmax=18 )) 
x2axisopts=(display=(ticks line) type=auto);
seriesplot x='date'n y='unemployment_rate_15_24'n / primary=true lineattrs=( color=cx963634 pattern=1 thickness=2) legendlabel="Youth (15-24 years) unemployment rate" NAME="SERIES";
seriesplot x='date'n y='unemployment_rate_15_'n / lineattrs=( color=cx538dd5 pattern=1 thickness=2) legendlabel="Overall (15+ years) unemployment rate" NAME="SERIES1";
discretelegend "SERIES" "SERIES1" / location=inside halign=right valign=top;
endlayout;
endgraph;
end;
run;

proc sgrender data = filename template=mysgplot;
run;
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-04-21 14:15:02

我认为在SGPLOT中不使用注释是不可能做到的。他们有一段很好的代码,可以用注释这里来实现这一点。

在GTL中,在9.4中引入了TICKVALUEROTATION,它需要与TICKVALUEFITPOLICY=ROTATE|ROTATEALWAYSSPLITTICKVALUE=FALSE一起使用。见此:

代码语言:javascript
运行
复制
data testdata;
  call streaminit(7);
  do timevar = 12900 to 16900 by 500;
    age=10+rand('Normal',5,2);
    output;
  end;
  format timevar date9.;
run;

proc template;
define statgraph mysgplot;
begingraph;
layout overlay /
cycleattrs=true 
xaxisopts=(label=" " offsetmax=0 type=time 
    timeopts=(tickvaluerotation=VERTICAL TICKVALUEFITPOLICY=rotatealways splittickvalue=false) )
yaxisopts=(label=" " type=linear linearopts=(tickvaluelist=(0 2 4 6 8 10 12 14 16 18) viewmin=0 viewmax=18 )) 
x2axisopts=(display=(ticks line) type=auto);
seriesplot x=timevar y=age
    / lineattrs=( color=cx538dd5 pattern=1 thickness=2) legendlabel="Overall (15+ years) unemployment rate" NAME="SERIES1";
discretelegend "SERIES" "SERIES1" / location=inside halign=right valign=top;
endlayout;
endgraph;
end;
run;

proc sgrender data = testdata template=mysgplot;
run;

我稍微简化了您的轴,以确保它的工作正常,但我认为大多数您的轴语句是可以的。

在9.3或更早的版本中,我认为您被批注或45度困住了。或者看看你能不能说服一个散点图画在轴外。或者用SERIESPLOT和散乱点画出你自己的斧头,但这似乎有点过头了。

下面是上面的代码:

票数 1
EN

Stack Overflow用户

发布于 2016-10-08 15:57:56

从SAS9.4 TS1M3中,只需要一行简单的代码:

代码语言:javascript
运行
复制
XAXIS VALUESROTATE=VERTICAL;

请参阅:http://support.sas.com/kb/48/432.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29763234

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档