转载:(中文翻译者)[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语言 如何为图片添加文字说明(转载)的更多相关文章

  1. 【Go语言绘图】图片添加文字(一)

    前一篇讲解了利用gg包来进行图片旋转的操作,这一篇我们来看看怎么在图片上添加文字. 绘制纯色背景 首先,我们先绘制一个纯白色的背景,作为添加文字的背景板. package main import &q ...

  2. 【Go语言绘图】图片添加文字(二)

    这一篇将继续介绍gg库中绘制文字相关的方法,主要包括:DrawStringAnchored().DrawStringWrapped().MeasureMultilineString().WordWra ...

  3. R语言在柱状图上添加文字

    代码示例: data <- data.frame(A = 1:2, B = 1:2, C = 1:2) data <- data.matrix(data) par(font = 2, lw ...

  4. php图片添加文字水印方法汇总

    方法一: <?php header("content-type:text/html;charset=utf-8"); //指定图片路径 $src = "img/a. ...

  5. php给图片添加文字水印方法汇总

    在php中要给图片加水印我们需要给php安装GD库了,这里我们不介绍GD库安装,只介绍怎么利用php给图片添加文字水印的4种方法的汇总.有需要的小伙伴可以参考下. 1: 面向过程的编写方法 1 2 3 ...

  6. ios图片添加文字或者水印

    在项目中,我们会对图片做一些处理,但是我们要记住,一般在客户端做图片处理的数量不宜太多,因为受设备性能的限制,如果批量的处理图片,将会带来交互体验性上的一些问题.首先让我们来看看在图片上添加文字的方法 ...

  7. php 图片添加文字水印 以及 图片合成(微信快码传播)

    1.图片添加文字水印: $bigImgPath = 'backgroud.png'; $img = imagecreatefromstring(file_get_contents($bigImgPat ...

  8. 利用php给图片添加文字水印--面向对象与面向过程俩种方法的实现

    1: 面向过程的编写方法 //指定图片路径 $src = '001.png'; //获取图片信息 $info = getimagesize($src); //获取图片扩展名 $type = image ...

  9. 一种基于重载的高效c#上图片添加文字图形图片的方法

    在做图片监控显示的时候,需要在图片上添加文字,如果用graphics类绘制图片上的字体,实现图像上添加自定义标记,这种方法经验证是可行的,并且在visual c#2005 编程技巧大全上有提到,但是, ...

随机推荐

  1. 【Linux】freetds安装配置连接MSSQL

    我使用的是freetds-0.91,下载地址:http://pan.baidu.com/s/1hq68rZY 安装编译(根据需要unixodbc): [root@zabbixserver / ]# t ...

  2. select,poll,epoll的归纳总结区分

    Select.Poll与Epoll比较 以下资料都是来自网上搜集整理.引用源详见文章末尾. 1 Select.Poll与Epoll简介 Select select本质上是通过设置或者检查存放fd标志位 ...

  3. RAW格式

    一.什么是RAW文件?RAW文件主要是一种记录了数码相机传感器的原始信息,同时伴随着一些由相机所产生的一些元数据(metadata,诸如IS0的设置.快门速度.光圈值.白平衡等)的文件.不同的相机制造 ...

  4. hdu1505

    the main algorithm as the 1506 #include <stdio.h> #include <iostream> #include <strin ...

  5. sotower1.5-LS_工作流容易出错的地方

    流程代码如下: 1>LeiSheng.WorkFlow.FlowInfo fInfo = new LeiSheng.WorkFlow.FlowInfo();                2&g ...

  6. 爱拼图游戏android源码完整版

    这个是一款爱拼图游戏源码完整版,该游戏源码比较完整的,可以支持音乐的播放在游戏的玩的过程中,还可以控制系统的声音等,可以支持多种图片的选择来进行玩的,还可以根据自己的爱好选择不同的难度来的,级别分为: ...

  7. ADO.NET中的Connection详解

    连接字符串 1.写法一 "Data Source=服务器名; Initial Catalog=数据库; User ID =用户名; Password=密码; Charset=UTF8; &q ...

  8. linux安装ftp服务器

    Ftp(文件传输协议) 概念 FTP是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”.用于Internet上的控制文件的双向传输.同时,它也是一个应用 ...

  9. 使用eclipse与jLink V8调试exynos 4412 u-boot

    /** ****************************************************************************** * @author    Maox ...

  10. 消息推送之GCM

    利用GCM进行消息推送 原理 1.接收端向GCM注册registerid 2.发送端发消息给GCM服务器 这个过程需要三个参数: (1)API Key (2)registerid (3)传递的数据 3 ...