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

R语言(4) plot函数介绍

目录

plot函数:

 type绘图类型

 一页多图画法

 pch点符号类型

cex控制点的大小

lty线条类型 

 lwd线条宽度

col颜色 

 xlim ylim 坐标轴取值范围

 main  sub 主副标题

xlab,ylab 标签 

plot函数:

 mtcars是一个内置的演示用的数据集,方便用户直接拿这些示例数据试验某些作图功能,下面使用mtcars作图演示。

 plot(mtcars$wt)

 plot(mtcars$wt,mtcars$disp)

 plot(mtcars)

 type绘图类型

p表示点,l表示线,b表示下划线,其他o,h,s,S

mtcars<-mtcars[order(mtcars$wt),]
plot(mtcars$wt,mtcars$disp,type='l')

 plot(mtcars$wt,mtcars$disp,type='b')

 plot(mtcars$wt,mtcars$disp,type='p')

 plot(mtcars$wt,mtcars$disp,type='o')

 plot(mtcars$wt,mtcars$disp,type='h')

 plot(mtcars$wt,mtcars$disp,type='s')

 plot(mtcars$wt,mtcars$disp,type='S')

 一页多图画法

par(mfrow=c(3,3))#三行三列
mtcars<-mtcars[order(mtcars$wt),]
plot(mtcars$wt,mtcars$disp,type='l')
plot(mtcars$wt,mtcars$disp,type='b')
plot(mtcars$wt,mtcars$disp,type='p')
plot(mtcars$wt,mtcars$disp,type='o')
plot(mtcars$wt,mtcars$disp,type='h')
plot(mtcars$wt,mtcars$disp,type='s')
plot(mtcars$wt,mtcars$disp,type='S')

 pch点符号类型

plot(mtcars$wt,mtcars$disp,pch=2)

 plot(mtcars$wt,mtcars$disp,pch=1)

 其余自己测试

cex控制点的大小

plot(mtcars$wt,mtcars$disp,pch=1,cex=1.5)

#默认是1, 1.5就是默认大小的1.5倍

lty线条类型 

par(mfrow=c(3,2))
plot(mtcars$wt,mtcars$disp,type='l',lty=1)
plot(mtcars$wt,mtcars$disp,type='l',lty=2)
plot(mtcars$wt,mtcars$disp,type='l',lty=3)
plot(mtcars$wt,mtcars$disp,type='l',lty=4)
plot(mtcars$wt,mtcars$disp,type='l',lty=5)
plot(mtcars$wt,mtcars$disp,type='l',lty=6)

 lwd线条宽度

plot(mtcars$wt,mtcars$disp,type='l',lty=1,lwd=0.5)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,lwd=2)

 

col颜色 

par(mfrow=c(3,4))
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col='blue')
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col='red')
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=1)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=2)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=3)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=4)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=5)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=6)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=7)
plot(mtcars$wt,mtcars$disp,type='l',lty=1,col=8)

#直接使用颜色名字或者数字1-8

#或者使用十六进制颜色或rgb函数

 xlim ylim 坐标轴取值范围

plot(mtcars$wt,mtcars$disp,type='l',xlim=c(3,4),ylim=c(300,400))

 main  sub 主副标题

plot(mtcars$wt,mtcars$disp,type='l',lty=1,main='qq折线图',sub='2022/10/1')

xlab,ylab 标签 

plot(mtcars$wt,mtcars$disp,type='l',lty=1,main='qq折线图',sub='2022/10/1',xlab='x轴标签',ylab='y轴标签')

相关文章:

  • JVM -- 垃圾回收器7种(四)
  • 模型调优:验证集的作用(就是为了调整超参数)
  • PyQt5之消息对话框
  • java计算机毕业设计校友闲置书籍管理平台源代码+数据库+系统+lw文档
  • Interactron | 体现自适应的目标检测器
  • javaEE---CSS
  • PCIE操作基础原理
  • Windows系统SVG图片预览插件
  • 2022.10.1模拟赛
  • 西瓜书研读——第三章 线性模型: 线性判别分析 LDA
  • 云计算概论 --云安全机制
  • java计算机毕业设计企业公开招聘系统源程序+mysql+系统+lw文档+远程调试
  • 谷粒学院16万字笔记+1600张配图(十五)——微信扫码登录
  • 详述进程概念【Linux】
  • VVC系列(一)VTM下载编译
  • $translatePartialLoader加载失败及解决方式
  • 《剑指offer》分解让复杂问题更简单
  • CentOS6 编译安装 redis-3.2.3
  • Java多态
  • JDK9: 集成 Jshell 和 Maven 项目.
  • MySQL-事务管理(基础)
  • PHP那些事儿
  • React+TypeScript入门
  • 安卓应用性能调试和优化经验分享
  • 从零开始学习部署
  • 仿天猫超市收藏抛物线动画工具库
  • 干货 | 以太坊Mist负责人教你建立无服务器应用
  • 回流、重绘及其优化
  • 入门级的git使用指北
  • (4)Elastix图像配准:3D图像
  • (NSDate) 时间 (time )比较
  • (TipsTricks)用客户端模板精简JavaScript代码
  • (第8天)保姆级 PL/SQL Developer 安装与配置
  • (附源码)ssm码农论坛 毕业设计 231126
  • (数据结构)顺序表的定义
  • (四)c52学习之旅-流水LED灯
  • (四)搭建容器云管理平台笔记—安装ETCD(不使用证书)
  • (算法)N皇后问题
  • (万字长文)Spring的核心知识尽揽其中
  • (原創) 物件導向與老子思想 (OO)
  • ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)
  • 、写入Shellcode到注册表上线
  • .bat批处理(七):PC端从手机内复制文件到本地
  • .desktop 桌面快捷_Linux桌面环境那么多,这几款优秀的任你选
  • .jks文件(JAVA KeyStore)
  • .NET Micro Framework初体验
  • .net php 通信,flash与asp/php/asp.net通信的方法
  • .net 写了一个支持重试、熔断和超时策略的 HttpClient 实例池
  • .NET国产化改造探索(三)、银河麒麟安装.NET 8环境
  • .NET中使用Redis (二)
  • .net中我喜欢的两种验证码
  • @ConditionalOnProperty注解使用说明
  • @ModelAttribute 注解
  • [ C++ ] STL_stack(栈)queue(队列)使用及其重要接口模拟实现
  • [ vulhub漏洞复现篇 ] ThinkPHP 5.0.23-Rce