0% found this document useful (0 votes)
41 views11 pages

Plot Qnorm Plot Normal

This document contains code to generate various probability distribution and 3D plots in R. It includes: - Code to plot normal, binomial, Poisson, gamma, and banding distributions. - Functions to plot love heart shapes, random walks, relationships and 3D surfaces. - Code uses built-in distribution functions and plots lines, polygons and surfaces in R.

Uploaded by

HaydarRP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views11 pages

Plot Qnorm Plot Normal

This document contains code to generate various probability distribution and 3D plots in R. It includes: - Code to plot normal, binomial, Poisson, gamma, and banding distributions. - Functions to plot love heart shapes, random walks, relationships and 3D surfaces. - Code uses built-in distribution functions and plots lines, polygons and surfaces in R.

Uploaded by

HaydarRP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Plot Qnorm Plot Normal

0.4
3
2

0.3
1

0.2
0
y

y
-1

0.1
-2
-3

0.0
0.0 0.2 0.4 0.6 0.8 1.0 -4 -2 0 2 4
x x

Plot Binomial Plot Poisson


0.08

0.12
0.10
0.06

0.08
0.04

0.06
y
y

0.04
0.02

0.02
0.00
0.00

0 20 40 60 80 100 0 20 40 60 80 100

x x
Plot Banding Gamma

1.0
0.8
0.6
y

0.4
0.2
0.0

0 2 4 6 8 10

Plot Banding Mean


0.4
0.3
0.2
y

0.1
0.0

-4 -2 0 2 4

Plot Kata Love


80
40
0
0.0 1.0 2.0 3.0

3
1
-1
-3
-3 -1 1 3

x
6
4
2
0

-3 -1 1 3

x
3
1
-1
-3

-3.0 -2.0 -1.0 0.0

Plot love 2D
10
5
0
y

-5
-10
-15

-15 -10 -5 0 5 10 15

x
Plot love 3D

Plot Tidak Jodoh


10
8

w
6
y

4
2
0

0 2 4 6 8 10

x
Plot Pacar Sekali

10
8
6 w
y

4
2
0

0 2 4 6 8 10

Plot Ngotot
10
8

w
6
y

4
2
0

0 2 4 6 8 10

x
Plot Random Walk

12
H

10
w
8

C
6
y

A
4

B
2
0

0 2 4 6 8 10 12

Plot Damn Lucky


10
8

w
6
y

4
2
0

0 2 4 6 8 10

x
bandingmean=function(){
x=seq(-4,4,by=0.01)
y=dnorm(x,mean=0,sd=1)
y1=dnorm(x,mean=1,sd=1)
y2=dnorm(x,mean=2,sd=1)
y3=dnorm(x,mean=3,sd=1)
y4=dnorm(x,mean=0,sd=2)
y5=dnorm(x,mean=0,sd=3)
y6=dnorm(x,mean=0,sd=4)
plot(x,y,col="red",type="l",lwd=1)
lines(x,y1,col="blue",lwd=1)
lines(x,y2,col="purple",lwd=1)
lines(x,y3,col="orange",lwd=1)
lines(x,y4,col="yellow",lwd=1)
lines(x,y5,col="green",lwd=1)
lines(x,y6,col="grey",lwd=1)
}
bandingmean()

win.graph()
bandinggamma=function(){
x=seq(0,10,by=0.1)
y=dgamma(x,shape=1,scale=1)
y1=dgamma(x,shape=1,scale=2)
y2=dgamma(x,shape=1,scale=3)
y3=dgamma(x,shape=1,scale=4)
y4=dgamma(x,shape=2,scale=1)
y5=dgamma(x,shape=3,scale=1)
y6=dgamma(x,shape=4,scale=1)
plot(x,y,col="red",type="l",lwd=1)
lines(x,y1,col="blue",lwd=1)
lines(x,y2,col="purple",lwd=1)
lines(x,y3,col="orange",lwd=1)
lines(x,y4,col="yellow",lwd=1)
lines(x,y5,col="green",lwd=1)
lines(x,y6,col="grey",lwd=1)
}
bandinggamma()

kata love :
par(mfrow=c(4,1),mar=c(2,2,2,2))
x=seq(0,3,by=0.01)
y=1/x
plot(x,y,type="l",col="red",lwd=2)
teta=seq(0,pi*2,by=0.001)
x=3*sin(teta)
y=3*cos(teta)
plot(x,y,type="l",col="red",lwd=2)
x=seq(-3,3,by=0.01)
y=abs(-2*x)
plot(x,y,type="l",col="red",lwd=2)
y=seq(-pi,pi,by=0.01)
x=-3*abs(sin(y))
plot(x,y,type="l",col="red",lwd=2)

love2d :
dat<- data.frame(t=seq(0, 2*pi, by=0.1) )
xhrt <- function(t) 16*sin(t)^3
yhrt <- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
dat$y=yhrt(dat$t)
dat$x=xhrt(dat$t)
with(dat, plot(x,y,type="l",col="red")
with(dat, polygon(x,y,type="l",col="red")
with(dat, polygon(x,y,type="l",col="red"))
tidakjodoh=function(){
x=c(0:10)
y=c(0:10)
plot(x,y,type="n")
abline(h=4,col="blue")
abline(h=6,col="red")
text(0,6.5,"w")
}
tidakjodoh()

pacarsekali=function(){
x=c(0:10)
y=c(0:10)
plot(x,y,type="n")
abline(h=6,col="red")
lines(c(0,10),c(0,10),col="blue")
text(0,6.5,"w")
}
pacarsekali()

ngotot=function(){
x=c(0:10)
y=c(0:10)
plot(x,y,type="n")
abline(h=6,col="red")
x1=seq(0,10,by=0.1)
y1=6*(1-exp(-x1))
lines(x1,y1,col="blue")
text(0,6.5,"w")
}
ngotot()
randomwalk=function(){
x=c(0:12)
y=c(0:12)
plot(x,y,type="n")
abline(h=8,col="red")
lines(c(0,2),c(4,4),type="l",col="blue")
lines(c(2,2),c(4,10),type="b",col="blue")
lines(c(2,4),c(10,10),type="l",col="blue")
lines(c(4,4),c(10,6),type="b",col="blue")
lines(c(4,6),c(6,6),type="l",col="blue")
lines(c(6,6),c(6,2),type="b",col="blue")
lines(c(6,8),c(2,2),type="l",col="blue")
lines(c(8,8),c(2,12),type="b",col="blue")
lines(c(8,10),c(12,12),type="l",col="blue")
lines(c(10,10),c(12,8),type="b",col="blue")
lines(c(10,12),c(8,8),type="l",col="blue")
text(0,8.5,"w")
text(1,4.5,"A")
text(3,10.5,"H")
text(5,6.5,"C")
text(7,2.5,"B")
}
randomwalk()

x=seq(0,100,by=1)
y=dbinom(x,size=100,prob=0.5)
plot(x,y,col="red")
y=dpois(x,10)
plot(x,y,col="red")

love3d=function(){
library("plot3D")
x=y=z=seq(-1.5,1.5,length.out=100)
xyz=mesh(x,y,z)
F=with(xyz,(x^2+(9/4)*y^2+z^2-1)^3-x^2*z^3-(9/80)*y^2*z^3)
isosurf3D(x,y,z,F,level=0,shade=0.8,col="red",main="Plot love 3D")
}
love3d()

You might also like