plot与legend画图与图例
画图与图例:
legend(x, y = NULL, legend, fill = NULL, col = par("col"),
border = "black", lty, lwd, pch,
angle = 45, density = NULL, bty = "o", bg = par("bg"),
box.lwd = par("lwd"), box.lty = par("lty"), box.col = par("fg"),
pt.bg = NA, cex = 1, pt.cex = cex, pt.lwd = lwd,
xjust = 0, yjust = 1, x.intersp = 1, y.intersp = 1,
adj = c(0, 0.5), text.width = NULL, text.col = par("col"),
text.font = NULL, merge = do.lines && has.pch, trace = FALSE,
plot = TRUE, ncol = 1, horiz = FALSE, title = NULL,
inset = 0, xpd, title.col = text.col, title.adj = 0.5,
seg.len = 2)
x, y |
X,y用于定位图例,也可用单键词"bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center" |
legend |
字符或表达式向量 |
fill |
用特定的颜色进行填充 |
col |
图例中出现的点或线的颜色 |
border |
当fill = 参数存在的情况下,填充色的边框 |
lty, lwd |
图例中线的类型与宽度 |
pch |
点的类型 |
angle |
阴影的角度 |
density |
阴影线的密度 |
bty |
图例框是否画出,o为画出,默认为n不画出 |
bg |
bty != "n"时,图例的背景色 |
box.lty, box.lwd, box.col |
bty = "o"时,图例框的类型,box.lty决定是否为虚线,box.lwd决定粗线,box.col决定颜色 |
pt.bg |
点的背景色 |
cex |
字符大小 |
pt.cex |
点的大小 |
pt.lwd |
点的边缘的线宽 |
x.intersp |
图例中文字离图片的水平距离 |
y.intersp |
图例中文字离图片的垂直距离 |
adj |
图例中字体的相对位置 |
text.width |
图例字体所占的宽度 |
text.col |
图例字体的颜色 |
text.font |
图例字体 |
merge |
logical, if TRUE,合并点与线,但不填充图例框,默认为TRUE |
trace |
logical; if TRUE显示图例信息. |
plot |
logical. If FALSE不画出图例 |
ncol |
图例中分类的列数 |
horiz |
logical; if TRUE,水平放置图例 |
title |
给图例加标题 |
inset |
当图例用关键词设置位置后,inset = 分数,可以设置其相对位置 |
xpd |
xpd=FALSE,即不允许在作图区域外作图,改为TRUE即可,与par()参数配合使用。 |
title.col |
标题颜色 |
title.adj |
图例标题的相对位置,0.5为默认,在中间。0最左,1为最右。 |
seg.len |
lty 与lwd的线长,长度单位为字符宽度 |
先画出每个样本的forehead位置的sweat gland 数量
1
|
plot (forehead~sample,pch=15,col= "DarkTurquoise" ,ylim= c (0,400),ylab= "Number of active sweat glands per cm2" ,main= "Number of active sweat glands per cm2 in forehead, forearm and back" ) #pch表示散点用什么形状表示,col表示颜色,ylim表示Y轴范围,ylab表示Y轴标题,main表示图片标题 |
接着画出每个样本forearm位置的sweat gland 数量
注意,这里不用plot函数画forearm和sample之间的关系,因为会把上面forehead和sample的图覆盖住,为了实现多个因变量和一个自变量在同一个图片里,我们要用points或者lines函数画其他因变量和自变量的值
1
|
points (sample,forearm,pch=16,col= "DeepPink" ,cex=1) #cex表示散点的大小 |
画出back位置的sweat gland 数量
1
|
points (sample,back,pch=17,col= "RosyBrown" ,cex=1) |
把14个样本在forehead,forearm和back不同位置的sweat gland 数量用线连起来
1
2
3
|
lines (forehead,col= "DarkTurquoise" ,lty=1) #lty=1表示用实线连起来 lines (forearm,col= "DeepPink" ,lty=2) #lty=2表示用虚线连起来 lines (back,col= "RosyBrown" ,lty=3) #lty=3表示用点线连起来 |
legend函数,图例说明:
1
|
legend (12,400, c ( "forehead" , "forearm" , "back" ),col= c ( "DarkTurquoise" , "DeepPink" , "RosyBrown" ),text.col= c ( "DarkTurquoise" , "DeepPink" , "RosyBrown" ),pch= c (15,16,17),lty= c (1,2,3)) #12表示x轴坐标为12,400表示y轴坐标为400,意思为图例的左边和上边界限,text.col表示图例文本颜色 |
最后,画出来的图片效果如下:
plot与legend画图与图例的更多相关文章
- matlab画图函数plot()/set/legend
简单plot()/legend/XY轴范围axis 除了坐标轴信息外还可以添加其它的信息,如所画曲线的信息等:测试代码如下 x=0:pi/20:2*pi; y1=sin(x); y2=cos(x); ...
- matplotlib中的legend()——用于显示图例
legend()的一个用法: 当我们有多个 axes时,我们如何把它们的图例放在一起呢?? 我们可以这么做: import matplotlib.pyplot as plt import numpy ...
- 增加图例 Legend和删除图例
private void button1_Click(object sender, System.EventArgs e) { //Get the GraphicsContainer IGraphic ...
- matplotlib中的legend()—显示图例
源自 matplotlib中的legend()——用于显示图例 -- 博客园 http://www.cnblogs.com/yinheyi/p/6792120.html legend()的一个用法: ...
- ggplot2 legend图例的修改
ggplot2中的legend包括四个部分: legend.tittle, legend.text, legend.key, legend.backgroud.针对每一部分有四种处理方式: eleme ...
- echart 饼图图例legend支持滑动
ps: 以下针对option操作 文章目录 图例过多加上滚动条图例形状图例自定义显示图例过多加上滚动条 legend:{ top:'50', bottom:'50', type:'scroll',} ...
- matlab的legend用法
用Matlab画图时,有时候需要对各种图标进行标注,例如,用“+”代表A的运动情况,“*”代表B的运动情况. legend函数的基本用法是: LEGEND(string1,string2,string ...
- Matlab设置Legend横排、分块
高级用法1:指定legend显示的位置: legend({'str1','str2','strn'},'Location','SouthEast'); 比较鸡肋,画好图后树手动拖动就好了 高级用法2: ...
- matlab 初级画图
matlab 初级画图 1.plot() plot(x,y) plots each vector pairs (x,y) 画图函数画出每个点 每组变量 plot (y) plots eac ...
随机推荐
- 第七周 linux如何装载和启动一个可执行文件
潘恒 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.实验内容 1.预处理. ...
- logstash 解析日志文件
input { file { path => "/usr/local/test/log.log" } } filter { grok { match => { &quo ...
- Balanced Ternary String CodeForces - 1102D (贪心+思维)
You are given a string ss consisting of exactly nn characters, and each character is either '0', '1' ...
- 菜鸟教程--AJAX
一.简介1.AJAX 是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术.2.AJAX = 异步 JavaScript 和 XML.3.通过在后台与服务器进行少量数据交换,AJAX 可以使网 ...
- [微软官网]windows server 内存限制
Memory Limits for Windows and Windows Server Releases https://docs.microsoft.com/zh-cn/windows/deskt ...
- [转帖]git、github、gitlab之间的关系
Git - 版本控制工具 Github - 一个网站,提供给用户空间创建git仓储,保存用户的一些数据文档或者代码等 GitLab - 基于Git的项目管理软件 Git分布式版本控制系统 Git是一款 ...
- Linux基础学习(3)--初学注意
第三章——初学注意 一.学习Linux的注意事项 1.Linux严格区分大小写 2.Linux中所有内容以文件形式保存,包括硬件: (1)硬盘文件是/dev/sd[a-p] (2)光盘文件是/dev/ ...
- 掌上电脑设备可以使用Ubuntu MATE 18.10 Linux映像了
就在几天前,Ubuntu 18.10发布了.操作系统被称为“Cosmic Cuttlefish”,有多种版本可供选择,除了常见的GNOME -- Xfce (Xbuntu), KDE (Kubuntu ...
- mysql5.7 rpm安装教程
注意版本和此次更新时间 2017-12-03 版本:mysql-5.7.20-1.el6.x86_64 环境:linux6.x 官方下载地址: wget https://dev.mysql.co ...
- hdu 5919 Sequence II (可持久化线段树)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5919 大致题意: 给你一个长度为n的序列,q个询问,每次询问是给你两个数x,y,经过与上一次的答案进行运算 ...