3

問題なくテキストを ggplot に追加できますgeom_text(cars データベースを使用した例):

ggplot(cars, aes(speed, dist), color='blue') + 
geom_point(size=0.8) + 
geom_text(y=25, x=5, aes(label=paste("sigma == 1"), size=1.5), 
    hjust=0, parse=TRUE, color='blue')

しかし、y スケールを対数に変更すると、グラフにテキストを表示できません。

ggplot(cars, aes(speed, dist), color='blue') + 
geom_point(size=0.8) + 
geom_text(y=25, x=5, aes(label=paste("sigma == 1"), size=1.5), 
    hjust=0, parse=TRUE, color='blue') + 
scale_y_log10()

テキストのサイズと位置を変更しようとしましたが、取得できないようです。

4

2 に答える 2

5

これは私のために働く:

require(ggplot2)
g <- ggplot(cars, aes(speed, dist), color='blue')
g <- g + geom_point(size=0.8)
g <- g + geom_text(aes(y=25, x=5, label=paste("sigma == 1"), size=1.5), hjust=0, parse=TRUE, color='blue')
g <- g + scale_y_log10()
g

http://www.r-fiddle.org/#/fiddle?id=GVWg1dDO

于 2015-01-09T13:07:24.083 に答える
3

これはよりうまく機能します:

ggplot(cars, aes(speed, dist), color='blue') + 
    geom_point(size=0.8) + 
    geom_text(y=2, x=5, aes(label=paste("sigma == 1"), size=1.5), 
        hjust=0, parse=TRUE, color='blue') + 
    scale_y_log10()

ここに画像の説明を入力

対数目盛に通常: 100 -> 2; 1000 -> 3; 0.1 -> -1; 0.01 -> -2

于 2018-06-26T00:27:25.560 に答える