R的画图
关于R基础
有3个需要总结的地方
- R的画图(统计学图,ggplot)
- R的基本语法
- R dataframe相关
Plot
plot(1,2)
plot(c(1, 2, 3, 4, 5), c(3, 7, 8, 9, 12))
x <- c(1, 2, 3, 4, 5)
y <- c(3, 7, 8, 9, 12)
plot(x, y)
其他参数:
type='l'main="My Graph"xlab="The x-axis"ylab="The y axis"col="red"cex=2, 点的大小,默认值为1。pch=25形状(值从0-25)lwd=2如果画的不是line,也会起作用lty=3linestyle, 只有在type=line的时候才会起作用 (值从0-6)
0removes the line1displays a solid line2displays a dashed line3displays a dotted line4displays a "dot dashed" line5displays a "long dashed" line6displays a "two dashed" line
#画两条线,一定是先plot后line
line1 <- c(1,2,3,4,5,10)
line2 <- c(2,5,7,8,9,10)
plot(line1, type = "l", col = "blue")
lines(line2, type="l", col = "red")
看完了line
abline(lm(y~x))
abline画回归线lm() linear-model用线性模型拟合回归线
title("AAA")
给图像添加题目
ggplot
library(ggplot)
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class))
#区别
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = "blue"))
ggplot(data = diamonds) + geom_bar(aes(x = cut, fill = cut)) + scale_fill_brewer(palette = "Dark2")
ggsave(file = "mygraph.png", plot = p)
- geom_smooth()
R的画图的更多相关文章
- R 语言画图的基本参数
R 语言画图的基本参数 点 点的种类 点的种类参数为 pch,每一种符号对应一个数字编号 # 点有25种,为了展示25种点 x = 1:25 y = 1:25 x ## [1] 1 2 3 4 5 6 ...
- R语言画图教程之盒形图
R语言画图教程之盒形图 我们之前有分享过一系列的R语言画图代码(PCA图.Pathway图.火山图.RDA图.热图),今天再来补充一个盒形图(箱形图)的代码. 以下代码只是示例,不能直接搬来用哦,注意 ...
- R语言画图小结
本文以1950年到2010年期间我国的火灾统计数据为例,数据如下所示: (0)加载数据 data<-read.csv("E:\\MyDocument\\p\\Data\\1950~20 ...
- R基本画图
参考内容:闻博,R语言的绘图功能及应用案例 https://wenku.baidu.com/view/80f22fa50029bd64783e2c22.html R画图是以函数操作为基本的画图模式. ...
- R语言画图实例-参考R语言实战
dose <- c(, , , ,) drugA <- c(, , , , ) drugB <- c(, , , , ) # 数据准备 opar <- par(no.reado ...
- R语言画图布局摆放(layout)
require(ggplot2) require(Cairo) require(grid) p = ggplot(iris,aes(x = Species,y = Sepal.Length,colou ...
- R语言画图基础参数设置
Graphical Parameters You can customize many features of your graphs (fonts, colors, axes, titles) th ...
- [R语言画图]气泡图symbols
绘制气泡图主要使用函数symbols(x,y,circle=r).当中x.y是坐标轴,r是每一个点的半径. x<-rnorm(10) y<-rnorm(10) r<-abs(rnor ...
- R语言︱画图
笔者寄语:不论画啥,你先plot准没错. plot 二维坐标绘图 dotchart 点图 barplot 条形图 hist 直方图 pie 饼图 points 添加点 lines 添加线 text 添 ...
- R语言画图
转http://www.cnblogs.com/jiangmiaomiao/p/6991632.html 0 引言 R支持4种图形类型: base graphics, grid graphics, l ...
随机推荐
- java的内存模型,jmm理解和(GC)垃圾回收时机。
jmm模型中的gc处理是在堆中回收. 1.新对象出来以后,先尝试在eden中放下,放不下的时候,进行一次ygc,只会在eden中回收,
- vscode工程目录文件及文件夹摘选
在工程工作区下新建一个.vscode 文件夹中并新建一个名为"settings.json"的文件,然后在 settings.json 中输入如下内容: { "search ...
- 如何设置表格的高度 element 的table 组件
<el-table :row-style="{ height: '30px' }" :cell-style="{ padding: 0 }" :data= ...
- format UTF-8 BOM by AX
#File CommaTextIo commaTextIo; FileIOPermission permission; CustTable custTable; str fileName = @&qu ...
- 一道网红题:Java值传递,答案开始看了不太懂,是不是涉及到了匿名类的实例化?
题目如下:看起来是值传递的考察... public class Test{ public static void main(String[] args){ int a = 10; int b = 10 ...
- ffmpeg设置超时时间
使用 -rw_timeout 参数 注意:1.参数单位是微秒,而不是秒.1秒(s)=1000000微秒(μs) 2.参数要放在开流前,否则不会生效 参考资料: FFmpeg命令读取RTMP流如何设 ...
- C++ read 读取字节数与设置不一样
当需要读取二进制文件时,C++可以采用ofstream流,并设置模式为ios::binary,就可以通过read函数进行按照字节读取了. 需要注意的是: 如果模式未进行设置,默认将以文本方式读取,此时 ...
- Asp.Net Core 程序开发技巧汇总
使用Sqlite数据库 创建项目 Asp.Net Core Web应用程序 Web应用程序 ASP.NET Core 2.2 NuGet管理,添加Sqlite数据库支持 Microsoft.Entit ...
- C#中冒号:使用场景
1. 继承类.实现接口与继承构造函数 ① 继承类 /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public p ...
- Python第六章实验报告
一.实验内容:<零基础学Python>第六章实例和实战,以及一道作业题 二.实验环境:IDLE Shell 3.9.7 三.实验目的和要求:掌握定义和调用函数.变量的作用域.匿名函数.参数 ...