VOOZH about

URL: https://qiita.com/Quantas/items/177bb213ebb7f5731b15

⇱ Rで散布図を描く ---初心者向け--- #初心者 - Qiita


👁 Image
1

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@Quantas(Quan tas)

Rで散布図を描く ---初心者向け---

1
Posted at
tags: rBasicLearning

散布図

使用するデータ

今回は, データとしてmtcarsを使う.

library(datasets)mtcars

散布図を使う場合

ヒストグラムは, 二つの量的データの関係性の概観を見る時に使う.

まずは, 量的データの概観を一つずつヒストグラムで見ていく

まずは, それぞれの変数のヒストグラムを見て, 概観を掴む.

hist(mtcars$wt)hist(mtcars$mpg)

👁 Image

散布図をプロットする

散布図は, 以下のコードで書くことができる.

plot(mtcars$wt,mtcars$mpg)

👁 Image

散布図に装飾を加える

散布図は, 以下のように装飾を加えることができる.
pchは, プロットの点の種類(pch = 19は丸)
cexは, プロットのサイズの拡大・縮小を表す(cex = 1.5は, プロットのサイズを1.5倍にする)
colは色, mainはグラフのタイトル, xlabはx軸ラベル, ylabはy軸ラベル.

plot(mtcars$wt,mtcars$mpg,pch=19,# Solid circlecex=1.5,# Make 150% sizecol="#cc0000",# Redmain="MPG as a Function of Weight of Cars",xlab="Weight (in 1000 pounds)",ylab="MPG")plot(mtcars$wt,mtcars$mpg,pch=3,# plus markcex=1.5,# Make 150% sizecol="#cc0000",# Redmain="MPG as a Function of Weight of Cars",xlab="Weight (in 1000 pounds)",ylab="MPG")plot(mtcars$wt,mtcars$mpg,pch=19,# Solid circlecex=0.3,# Make 30% sizecol="#cc0000",# Redmain="MPG as a Function of Weight of Cars",xlab="Weight (in 1000 pounds)",ylab="MPG")

👁 Image

1

Go to list of users who liked

0
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1

Go to list of users who liked

0