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 编程技巧大全上有提到,但是, ...
随机推荐
- Anaconda日志
https://fedoraproject.org/wiki/Anaconda/Logging Anaconda日志 centos7 anaconda安装日志目录 /var/log/anaconda ...
- 通用简单的 分页 SQL
select ID,TITLE,CONTENT,USERNAME,REALNAME,UNIT,UNITID,NOWTIMES,ACCEPTERID,ACCEPTERNAM ...
- 百度地图API示例之添加自定义控件
代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...
- 服务器time_wait状态原因
通信双方建立TCP连接后,主动关闭连接的一方就会进入TIME_WAIT状态 TIME_WAIT状态的时间是2倍的MSL(最大生存时间),在TIME_WAIT状态TCP连接实际上已经断掉,但是该插口又不 ...
- Longest Common Prefix [LeetCode 14]
1- 问题描述 Write a function to find the longest common prefix string amongst an array of strings. 2- 思路 ...
- app开发版面设计原则
(1) 单纯:形象和色彩必须简单明了(也就是简洁性). (2) 统一:造型与色彩必须和谐,要具有统一的协调效果. (3) 均衡:整个画面须要具有魄力感与均衡效果. (4) 展现重点:构成要素必须化繁为 ...
- Tornado小记 -- 模板中的Handler
在Tornado的前端页面模板中,Tornado提供了一些对象别名来快速访问对象,具体定义可以参考Tornado官方文档! 这里我想将的是Handler这个对象,Handler指向的处理当前这个页面的 ...
- JQuery.tmpl()的用法
动态请求数据来更新页面是现在非常常用的方法,现在通过Ajax请求返回的数据更多的是json对象, 为了解决js动态拼接数据这方面的问题,JavaScript 也可以利用模版来解决这些问题,比如基于 j ...
- js对象与this指向
创建对象的方法 1.对象字面量法 var obj={} var obj={ 'first-name':'Tom', 'last-name':'bush', age:24, Family:{ Broth ...
- set_exception_handler 和 set_error_handler 函数
定义和用法 set_exception_handler() 函数设置用户自定义的异常处理函数. 该函数用于创建运行时期间的用户自己的异常处理方法. 该函数会返回旧的异常处理程序,若失败,则返回 nul ...