天天看點

R-散點圖

> x1=round(rnorm(10,mean=77,sd=9))
> x2=round(rnorm(10,mean=85,sd=20))
> plot(x1,x2)
           

如下圖

R-散點圖
> plot(x1,x2,
 main = "analysis",xlab = "mathermatical analysis",ylab="linear algebra",xlim = c(,),ylim = c(,),
 xaxs="i" ,# Set axis style as internal
 yaxs="i", # Set y axis style as internal 
 col="red",# Set the color of plotting symbol to red 
 pch=)# Set the plotting symbol to filled dots 
           
R-散點圖

連線圖

> a=c(,,,,)
> b=c(,,,,)
> plot(a,b,type="l")
           
R-散點圖

多條曲線的效果

> tokyo=round(rnorm(,mean=,sd=))
> tokyo
 []        
 []  

> newwork=round(rnorm(,mean=,sd=))
> newwork
 []          

> lines(newwork,type="l",col="blue",lwd=)
> longdon=round(rnorm(,mean=,sd=))
> lines(longdon,type="l",col="blue",lwd=)
           
R-散點圖

## 向日葵散點圖 ##

用來克服散點圖中資料點重疊問題

在有重疊的地方用一朵“向日葵花”的花瓣數目來表示重疊資料的個數

> sunflowerplot(iris[,:],col="gold",seg.col="gold")
           
R-散點圖

散點圖集

  • 便利樣本中全部的變量配對畫出二進制圖
  • 直覺地了解所有變量之間的關系
    pairs(iris[,1:4])
    R-散點圖

散點圖集

  • 用plot 也可以實作同樣的效果
> plot(iris[,1:4],main="Relaationships between",pch=19,col="blue",cex=0.9)

![這裡寫圖檔描述](https://img-blog.csdn.net/20180217145322399?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA0Mzc2Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70) 
           
  • 利用par()在同一個device 輸出多個散點圖
  • Par 指令博大精深,用于設定繪圖參數,Help(par)

    關于繪圖參數

    help(par)

    colors()

    R-散點圖
    繪圖裝置

dev.cur()

dev.list()

dev.next(which=dev.cur())

dev.prev(which=dev.cur())

dev.off(which=dev.cur())

dev.set(which=dev.next())

dev.new(…)

graphics.off()

x1=c(1:3)

x1

[1] 1 2 3

x2=c(4,2,6)

x2

[1] 4 2 6

plot(x1,x2)

![這裡寫圖檔描述](https://img-blog.csdn.net/20180217150859936?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA0Mzc2Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
           

x3=c(3,4,2,5)

x4=c(5,4,9,7)

plot(x3,x4)

![這裡寫圖檔描述](https://img-blog.csdn.net/20180217151136466?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA0Mzc2Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
           

dev.new()

NULL

plot(x1,x2)

dev.list()

RStudioGD png windows

2 3 4

![這裡寫圖檔描述](https://img-blog.csdn.net/2018021715154281?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA0Mzc2Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
           

dev.cur()

windows

4

dev.next()

RStudioGD

2

dev.cur()

windows

4

**三維散點圖**
**安裝工具包**
           

install.packages(“scatterplot3d”)

Installing package into ‘C:/Users/nanji/Documents/R/win-library/3.0’

(as ‘lib’ is unspecified)

有二進制版本(将被安裝),但源代碼版本是後來的:

binary source

scatterplot3d 0.3-35 0.3-40

trying URL ‘https://cran.rstudio.com/bin/windows/contrib/3.0/scatterplot3d_0.3-35.zip’

Content type ‘application/zip’ length 289696 bytes (282 Kb)

opened URL

downloaded 282 Kb

package ‘scatterplot3d’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in

C:\Users\nanji\AppData\Local\Temp\RtmpEJLAN9\downloaded_packages

scatterplot3d(iris[2:4])

Error: could not find function “scatterplot3d”

scatterplot3d::scatterplot3d(iris[2:4])

x<-y<-seq(-2*pi,2*pi,pi/15)

f<-function(x,y)sin(x)*sin(y)

z<-outer(x,y,f)

contour(x,y,z,col=”blue”)

![這裡寫圖檔描述](https://img-blog.csdn.net/20180217155554311?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA0Mzc2Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
           

persp(x,y,z,theta=30,phi=30,expand=0.7,col=”lightblue”)

“`

R-散點圖
R