美文网首页
2018-01-18 R

2018-01-18 R

作者: 薛定喵喵喵 | 来源:发表于2018-01-18 23:54 被阅读0次

Day 1

重新学习R

使用R和相关数据

绘制简单图表

和matlab差不多

1. Intro


setwd( "F:/Storage/Documents/GitHub/R/W2" ) set working directory

read.csv("datasaurus.csv") csv read~

summary(d12)

names(d12) for names of column

d12$x picking column

plot( dino$x, dino$y )

image
dev.new() #new graphics device/board

d12$dataset=="star"   #output True,false of ==

d12[d12$dataset=="star", ] #output true data

line graph is produced by type ='l'

points are drawn by type ='p'

plot(dino$x, dino$y, type = 'l' , col="blue", lwd=2) #lwd=linewide

connected according to the data order

image
plot(dino$x, dino$y, type = 'p' , col="blue",cex =5)  #cex- point size
image

2. Basic

par( mfrow=c(3,3) ) rows,columns

plot(dino$x, dino$y, type = 'p' )

plot(dino$x, dino$y, type = 'l' )

plot(dino$x, dino$y, type = 'n' )

plot(dino$x, dino$y, type = 'h' )

plot(dino$x, dino$y, type = 'o' )

plot(dino$x, dino$y, type = 'b' )

plot(dino$x, dino$y, type = 'c' )

plot(dino$x, dino$y, type = 's' )

plot(dino$x, dino$y, type = 'S' )

"p" for points,

"l" for lines,

"b" for both,

"c" for the lines part alone of "b",

"o" for both ‘overplotted’,

"h" for ‘histogram’ like (or ‘high-density’) vertical lines,

"s" for stair steps,

"S" for other steps,Going from (x1; y1) to (x2; y2) with x1 < x2,

type = "s" moves first horizontal, then vertical, whereas type = "S" moves the other way around.

"n" for no plotting.

plot(dino$x, dino$y, type = 'l' , col="blue", lty=2,lwd=2) #lwd=linewide lty=linetype
par(mfrow=c(1,2), mar=c(4,4,2,1)) # mar=margin to 4 corner. c is fixed function.
plot(dino$x, dino$y, axes=F ) #axes=F false for axes
axis(1, at = c(40,60,100), labels = c("OUT", "OF", "DATA")) # draw axes 1 at c

plot( dino$x, dino$y,
      type='p', # a plot with points
      pch = 1,# using open circles as the points
      col="black", # with a black as the colour
      axes=T, # including axes
      main = "", # no title is specified
      xlab = "x", # uses the variable name
      ylab = "y", #also the variable name
      cex = 1, # the point size
      asp = 0, # each interval on the x axis scales to 1 unit on the y axis
      ann = T, # annotation is switched on, e.g. axis labels
      bty = "o", # the box type drawn around the plot
      cex.axis = 1, # the relative size of axis text
      cex.lab = 1, # and the relative sixe of the labels
      col.axis="black", # # the axis colour
      col.lab="black", # the label colour
      fg="black", # colour for axis ticks and teh bounding box
      las=0, # rotation of the text in axis labels
      xaxs="r", # controls the axes range, the default extends the data range by 4%
      yaxs="r", # and a sepearte control for the y axis
      xaxt="s", # tells R if we want an x axis
      yaxt="s", # and for the y axis
      # there are more arguments and defaults ... 
      # which you can find in the documentation for 'par' and 'plot'
      # aswell as for other specific plot types
)   

4.Append

Following is a chart of PCH symbols used in R plot. When the PCH is 21-25, the parameter "col=" and "bg=" should be specified. PCH can also be in characters, such as "#", "%", "A", "a", and the character will be ploted.


image.png

Values pch=26:32 are currently unused, and pch=32:255 give the text symbol in a single-byte locale. In a multi-byte locale such as UTF-8, numeric values of pch greater than or equal to 32 specify a Unicode code point. If pch is an integer or character NA or an empty character string, the point is omitted from the plot. Value pch="." is handled specially. It is a rectangle of side 0.01 inch (scaled by cex). In addition, if cex = 1 (the default), each side is at least one pixel (1/72 inch on the pdf, postscript and xfig devices).

image.png image.png

相关文章

  • 2018-01-19

    2018-01-18 文闻13873137878 2018-01-18 20:29 · 字数 150 · 阅读 0...

  • 素描石膏头像-海盗

    2018-01-18

  • 2018-01-22

    2018-01-18 侯圈圈 2018-01-18 10:29 · 字数 940 · 阅读 0 · 日记本 大家好...

  • 2018-01-18

    2018-01-18 禾隆李亮 2018-01-18 21:35 · 字数 342 · 阅读 4 · 日记本 20...

  • 2018-01-18 R

    Day 1 重新学习R 使用R和相关数据 绘制简单图表 和matlab差不多 1. Intro line gra...

  • 10_Centos的一些常用设置

    时间:2018-01-18 作者:魏文应 一、设置自定义快捷键启动Terminal: 打开:Setthings(设...

  • 我的母亲

    2018-01-18 文/大耳朵 图/网络 1 在外人眼里,我的母亲就是个地地道道的...

  • 2018-01-18周四 祷告词

    2018-01-18为自己祷告: 热情款待!(创19:3) 【经文】【创 19:3】 罗得切切地请他们,他们这才进...

  • 01_linux系统设置相关操作

    时间:2018-01-18 作者:魏文应 一、磁盘操作: 查看磁盘大小: fdisk -l 直观显示磁盘大小: d...

  • 2019-05-15

    4分钟读精华 | 麦肯锡笔记思考法 DPMLeader TIM辰天 2018-01-18 “通过搜寻并定义核心问题...

网友评论

      本文标题:2018-01-18 R

      本文链接:https://www.haomeiwen.com/subject/xnbgoxtx.html