2

私はこれに対する答えを探しましたが、見つけられませんでした.ggplot2を使用して、描画した後に一連の密度を描画します。左上隅に注釈を付けることができるように、xスケールとyスケールを取得する必要があります- ここに私のコードがあります:

gg= qplot(ExpRef,geom='density',color=IOL,fill=IOL,alpha=0.8,data=tmp2,
        main=mtitle,xlab ="Expected Refraction",cex.axis=3.0,font.axis = 2)  #bold and cesx = multiplier);
ggp = gg + geom_vline(data=data.frame(x=0,y=0),xintercept=means, lwd= 2,color=I("red")) ;
ggp = gg + geom_vline(data=data.frame(x=0,y=0),xintercept=PlanRef, lwd= 2,color=I("green")) ;
ggp = ggp + annotate("text",x=PlanRef, y = 1,  label=paste('Planned Refraction'),angle=90,size=7.0,colour='black', hjust = 0, vjust = 0)

ggp = ggp + annotate("text",x=SRKTRef, y = 0,label=paste('SRKT IOL-->'),angle=90,size=6.0,colour='yellow', hjust = 0, vjust = 0);
  • したがって、最後の行で、注釈をグラフィックの上部に配置するためにyの最大値を知る必要があります-密度グラフレイヤーで計算されたスケールを取得する方法はありますか? ありがとう
4

1 に答える 1

3

-Infプロット領域の境界の注釈には、 (左/下) または+Inf(右/上)を使用できます。

qplot(1:10, rnorm(10)) + 
annotate("text", x=Inf, y=-Inf, 
         label="bottom-right", vjust=-0.5, hjust=1)
于 2013-05-13T16:01:15.377 に答える