当前位置: 首页 > news >正文

R语言 如何为图片添加文字说明(转载)

转载:(中文翻译者)[http://blog.csdn.net/chen790646223/article/details/49766659]
(原文链接)[http://datascienceplus.com/adding-text-to-r-plot/ ]

下面介绍了n中为图片添加文字的方法。

# 利用layout函数分割屏幕
layout(matrix(c(1,1,2,2), 2, 2, byrow = T), heights = c(4,1))

# 随意画一张图
plot(rnorm(10),ylab="", xlab="Use the xlab argument", main="Use the title", ty="o", pch=19)

# 添加文字说明
mtext("Use the mtext() function")
temp <- locator(1) # 在图表上,你喜欢的地方点击一下,文字就出来了
text(temp,"Use the text() with or without the locator() function")

# 用下面的Corner_text函数添加文字(自己编写的函数):
Corner_text <- function(text, location="topright"){
legend(location,legend=text, bty ="n", pch=NA) 
}
Corner_text(text="Use Corner_text() function")
Corner_text(text="Use the Corner_text() function",location= "bottomright")

# 利用函数title 添加文字说明 
title(sub="Add subtitle using the title() function")

# 利用包gplots添加更多文字
library(gplots)

# ?textplot # 查询这个包的信息

# layout.show(2) # 在分割屏幕的中间显示内容(上面的屏幕和下面的屏幕之间)
temptext1 <- "Add here notes. The plot above represents 10 random points drawn from Normal distribution. The plot is generated in order 
to visualize all the different options one can use for adding text to a plot. 
You can control this text size using the usual \"cex\" argument.
\nYou can increase readability if you skip lines. 
\nUse this space when you have complicated charts that require some more details. Add explanations and preemt possible questions, by that 
saving readers' time (e.g. \"is it percentage or basis points?\" )."
temptext2 <-  "You can also add more text in the usual way by using again the locator(1)+text() functions" 
textplot(temptext1, valign="center", cex=0.8, halign= "left", mar=c(0,0,0,0), col=2) 

# mar=c(0,0,0,0) 除去页面空白
temp <- locator(1)
text(temp, temptext2,col=4)

转载于:https://www.cnblogs.com/steamed-bread/p/5397425.html

相关文章:

  • 【烈日炎炎战后端 】MyBatis(0.4万字)
  • Windows Docker的有趣事实
  • RSD和wlwmanifest是什么
  • 【烈日炎炎战后端】Zookeeper(0.5万字)
  • iOS 中runtime的运用原理
  • 【烈日炎炎战后端】Elecsticsearch(1.5万字)
  • TCP协议三次握手和四次挥手
  • 【烈日炎炎战后端】Nginx(0.3万字)
  • ESLint简单操作
  • 整体管理、范围管理
  • 【烈日炎炎战后端】编程题总结(13.3万字)
  • D3导出png,保存到本地
  • Yii2批量插入数据
  • Java垃圾回收机制
  • 我建了一个叫Hello World的项目
  • ➹使用webpack配置多页面应用(MPA)
  • Asm.js的简单介绍
  • CSS 专业技巧
  • CSS居中完全指南——构建CSS居中决策树
  • Linux后台研发超实用命令总结
  • PHP的Ev教程三(Periodic watcher)
  • python 学习笔记 - Queue Pipes,进程间通讯
  • Python3爬取英雄联盟英雄皮肤大图
  • SpringBoot几种定时任务的实现方式
  • V4L2视频输入框架概述
  • vue-router的history模式发布配置
  • Webpack 4 学习01(基础配置)
  • webpack入门学习手记(二)
  • 技术发展面试
  • 聚簇索引和非聚簇索引
  • 那些被忽略的 JavaScript 数组方法细节
  • 如何正确配置 Ubuntu 14.04 服务器?
  • 设计模式 开闭原则
  • 使用parted解决大于2T的磁盘分区
  • 微信小程序--------语音识别(前端自己也能玩)
  • 译有关态射的一切
  • 阿里云移动端播放器高级功能介绍
  • 交换综合实验一
  • ​Distil-Whisper:比Whisper快6倍,体积小50%的语音识别模型
  • ​卜东波研究员:高观点下的少儿计算思维
  • # 手柄编程_北通阿修罗3动手评:一款兼具功能、操控性的电竞手柄
  • #HarmonyOS:软件安装window和mac预览Hello World
  • #我与Java虚拟机的故事#连载16:打开Java世界大门的钥匙
  • (day6) 319. 灯泡开关
  • (poj1.2.1)1970(筛选法模拟)
  • (附源码)基于SSM多源异构数据关联技术构建智能校园-计算机毕设 64366
  • (附源码)计算机毕业设计高校学生选课系统
  • (论文阅读40-45)图像描述1
  • (原創) 是否该学PetShop将Model和BLL分开? (.NET) (N-Tier) (PetShop) (OO)
  • (转贴)用VML开发工作流设计器 UCML.NET工作流管理系统
  • .NET构架之我见
  • .net获取当前url各种属性(文件名、参数、域名 等)的方法
  • ::什么意思
  • @Bean, @Component, @Configuration简析
  • @Not - Empty-Null-Blank