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)
R语言 如何为图片添加文字说明(转载)的更多相关文章
- 【Go语言绘图】图片添加文字(一)
前一篇讲解了利用gg包来进行图片旋转的操作,这一篇我们来看看怎么在图片上添加文字. 绘制纯色背景 首先,我们先绘制一个纯白色的背景,作为添加文字的背景板. package main import &q ...
- 【Go语言绘图】图片添加文字(二)
这一篇将继续介绍gg库中绘制文字相关的方法,主要包括:DrawStringAnchored().DrawStringWrapped().MeasureMultilineString().WordWra ...
- R语言在柱状图上添加文字
代码示例: data <- data.frame(A = 1:2, B = 1:2, C = 1:2) data <- data.matrix(data) par(font = 2, lw ...
- php图片添加文字水印方法汇总
方法一: <?php header("content-type:text/html;charset=utf-8"); //指定图片路径 $src = "img/a. ...
- php给图片添加文字水印方法汇总
在php中要给图片加水印我们需要给php安装GD库了,这里我们不介绍GD库安装,只介绍怎么利用php给图片添加文字水印的4种方法的汇总.有需要的小伙伴可以参考下. 1: 面向过程的编写方法 1 2 3 ...
- ios图片添加文字或者水印
在项目中,我们会对图片做一些处理,但是我们要记住,一般在客户端做图片处理的数量不宜太多,因为受设备性能的限制,如果批量的处理图片,将会带来交互体验性上的一些问题.首先让我们来看看在图片上添加文字的方法 ...
- php 图片添加文字水印 以及 图片合成(微信快码传播)
1.图片添加文字水印: $bigImgPath = 'backgroud.png'; $img = imagecreatefromstring(file_get_contents($bigImgPat ...
- 利用php给图片添加文字水印--面向对象与面向过程俩种方法的实现
1: 面向过程的编写方法 //指定图片路径 $src = '001.png'; //获取图片信息 $info = getimagesize($src); //获取图片扩展名 $type = image ...
- 一种基于重载的高效c#上图片添加文字图形图片的方法
在做图片监控显示的时候,需要在图片上添加文字,如果用graphics类绘制图片上的字体,实现图像上添加自定义标记,这种方法经验证是可行的,并且在visual c#2005 编程技巧大全上有提到,但是, ...
随机推荐
- PHP:PHP页面编码问题(转载)
MySQL数据库编码.html页面编码.PHP或html文件本身编码要全部一致. 1.MySQL数据库编码:建立数据库时指定编码(如gbk_chinese_ci),建立数据表.建立字段.插入数据时不要 ...
- c++ builder TListView控件按字符串排序(根据网上代码亲测ok)
//--------------------------------------------------------------------------- /* 首先将一个列表框控件安放在Form上, ...
- CentOS 6.x 播放 mp3 音乐 —— 成功
参考:http://blog.chinaunix.net/uid-14735472-id-3472898.html centos 6.x 添加 rpmforge 源--- CentOS 6.x 安装 ...
- win7启动文件修复
1:在xp下运行bcdedit.exe(这软件在windows 7的系统盘下 就在你的c:\windows\system32\这里2:将这软件复制到c盘根目录下3:进入命令提示符 输入 c:4:输入 ...
- Linux系统在嵌入式硬件上的移植
========================= 基本常识 ========================= 一. Linux系统的基本构成: 1. loader 2. ...
- 2_JavaScript日期格式化
第二章 JavaScript 时间格式化 2.1 Ticks 转换为常规日期 2.2 常规日期格式化 <input type="button" value=&qu ...
- iOS中UIKit——UIFont得到iOS设备上的系统字体
for (NSString *fontFamily in [UIFont familyNames]) { NSLog(@"字体家族是:%@",fontFamily); for(N ...
- Entity Framework with NOLOCK
在SqlServer中,频繁在同一个数据库表同时进行读写的时候,会存在锁的问题,也就是在前一个insert.update.delete事务操作完毕之前,你不能进行读取,必须要等到操作完毕,你才能进行s ...
- 记 移动端页面中莫名其妙的渲染BUG
问题描述: 在一个很简单的测试页面中 简单的两块布局,上下两块均没有单独设置字体大小,都用body继承的大小,即40px.我们现在给第一个块.fl 加上浮动 float:left; 另外一个块处于正 ...
- Linux安装配置php环境的方法
本文实例讲述了Linux安装配置php环境的方法.分享给大家供大家参考,具体如下: 1.获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.g ...