2012-08-24 39 views
4

在我的代码中,读取数据以绘制极坐标图像。 但是“0/360”位居榜首。我怎样才能将它向右旋转90度?如何设置R的ggplot2中的“零”oritentation?

ggplot(polar, aes(x=angle, y=distance)) + coord_polar(start=0) + geom_point() + 
    scale_x_continuous(breaks=seq(0, 360, by=30), expand=c(0,0), lim=c(0, 360))+ 
    scale_area() 

全过程和所得的图形在此描述: http://keveting.blogspot.tw/2012/08/r-ggplot2-code.html

coord_polar用于该文档:

开始:从以弧度方向12时偏移量:1,顺时针; -1,逆时针

所以我试图

ggplot(polar, aes(x=angle, y=distance)) + 
    coord_polar(***start = 90, direction = -1***) + 
    geom_point() + scale_x_continuous(breaks=seq(0, 360, by=30), expand=c(0,0), 
    lim=c(0, 360)) + scale_area() 

但它仍然没有旋转90度的情节我想要的方式的权利。

回答

8

我认为这是你在找什么:

ggplot(polar, aes(x=angle, y=distance)) + 
    coord_polar(start = 1.57, direction=1) + geom_point() + 
    scale_x_continuous(breaks=seq(0, 360, by=30), expand=c(0,0), lim=c(0, 360)) + 
    scale_area() 

enter image description here

为纽带的coord_polar文件说,该start弧度(不度)和偏移你想顺时针旋转它(所以direction=1)。