プロが教える店舗&オフィスのセキュリティ対策術

画像のような図はどのように描くのでしょうか?
よろしくお願いします。

「プログラミング言語 R グラフ」の質問画像

A 回答 (2件)

企業で統計を推進する立場の者です。



極方程式図形の描画ですね。これは比較的簡単です。
すみませんが、中華文字は扱えません。あと、座標軸の拡大縮小の微調整はご自分でやって下さい。

~~~~~~~~~~~~~~~~~~~~~~

# 極方程式が与えられている図形の描画

# 計算点を与える

theta <- seq(0, 2 * pi, by = 0.001)

# 極座標→直交座標変換の関数を用意する

polar2ortho <- function(r, theta){
x <- r * cos(theta)
y <- r * sin(theta)
return(data.frame(x, y))
}

# プロット条件

par(mfrow = c(2, 2))
par(pty = "s")

# Four leaves Rose 図形
# ρ=sin2θ

r <- sin(2 * theta)
plot(polar2ortho(r, theta), type = "l",
xlim = c(-1, 1), ylim = c(-1, 1),
main = c("Four leaves Rose"))

abline(h = 0)
abline(v = 0)

# Limacon 図形
# ρ=0.5+cosθ

r <- 2 * (0.5 + cos(theta))
plot(polar2ortho(r, theta), type = "l",
xlim = c(-0.5, 3.5), ylim = c(-2, 2),
main = c("Limacon"))

abline(h = 0)
abline(v = 0)

# Cardioid 図形
# ρ=1-sinθ

r <- 1 - sin(theta)
plot(polar2ortho(r, theta), type = "l",
xlim = c(-1.5, 1.5), ylim = c(-2.5, 0.5),
main = c("Cardioid"))

abline(h = 0)
abline(v = 0)

# Lemniscale 図形
# ρ=a√2cos2θ・・・ただし√ 内が負の場合を除く

r <- 2/3 * sqrt(ifelse(2 * cos(2 * theta) < 0, 0, 2 * cos(2 * theta)))
plot(polar2ortho(r, theta), type = "l",
xlim = c(-1.2, 1.2), ylim = c(-1.2, 1.2),
main = c("Lemniscale"))

abline(h = 0)
abline(v = 0)

~~~~~~~~~~~~~~~~~~~~~~
「プログラミング言語 R グラフ」の回答画像2
    • good
    • 0

# Four-leaved rose


theta = seq(0, 2*pi, length=100)
r = 2*sin(2*theta)
plot(r*cos(theta), r*sin(theta), type="l", axes=T, xlab="x", ylab="y", bty="o",
main="Four-leaved rose")
abline(v=0); abline(h=0)

# Limacon

a = 1
b = 2
theta = seq(0, 2*pi, length=100)
r = a + b*cos(theta)
plot(r*cos(theta), r*sin(theta), type="l", axes=T, xlab="x", ylab="y", bty="o",
main="Limacon")
abline(v=0); abline(h=0)

# Cardioid

a = 1
b = 1
theta = seq(0, 2*pi, length=100)
r = a - b*sin(theta)
plot(r*cos(theta), r*sin(theta), type="l", axes=T, xlab="x", ylab="y", bty="o",
main="Cardioid")
abline(v=0); abline(h=0)

# Leminiscate

a = 0.8
theta = seq(0, 2*pi, length=10000)
r = sqrt((a^2)*cos(2*theta))
plot(r*cos(theta), r*sin(theta), type="l", axes=T, xlab="x", ylab="y", bty="o",
main="Lemniscate")
abline(v=0); abline(h=0)
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!