Jos*_*eke 3 text r ggplot2 geom-text
我可以使用geom_text就好了(使用汽车数据库的示例)将文本添加到 ggplot :
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')
Run Code Online (Sandbox Code Playgroud)
但是当我将 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()
Run Code Online (Sandbox Code Playgroud)
我试过改变文本大小和位置,但似乎无法理解。
这对我有用:
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
Run Code Online (Sandbox Code Playgroud)
http://www.r-fiddle.org/#/fiddle?id=GVWg1dDO
| 归档时间: |
|
| 查看次数: |
1697 次 |
| 最近记录: |