R基础绘图—散点图&线图
title: “R Graph”
author: “intro”
date: “2022/1/18”
output:
pdf_document: default
html_document: default
在这里插入代码片
knitr::opts_chunk$set(echo = TRUE)
Basic Graph Functions
scatter plot
cars <- cars
str(cars)
head(cars)


cars <- cars
str(cars)
head(cars)
plot(cars$dist~cars$speed, # y~x
pch=19,#Set the plotting symbol to filled dots
col='lightblue',#Set the color of plotting symbol to red
main="Relationship between car distance & speed", # Plot aTitle
xlab="Speed (miles per hour)", #X axis title
ylab="Distance travelled (miles)", #Y axis title
xlim=c(0,30), #Set x axis limits from 0 to 30
ylim=c(0,140), #Set y axis limits from 0 to 140
xaxs="i", #Set x axis style as internal
yaxs="i", #Set y axis style as internal
)

line graphs
plot(cars$dist~cars$speed,
type="l", #Specify type of plot as l for line
col='blue',
main="Relationship between car distance & speed",
xlab="Speed miles per hour",
ylab="Distance travelled (miles)")

R语言绘图教程
本文介绍了如何使用R语言进行基础绘图操作,包括散点图和线图的绘制方法。通过具体的实例展示了如何设置图表的颜色、符号样式以及轴的范围等属性。
2316

被折叠的 条评论
为什么被折叠?



