simpan=read.table("~/STATISTIKA/Data3.5.csv", header = TRUE, sep=",") #membaca data
simpan
## Produk Jumlah
## 1 A 12
## 2 B 5
## 3 C 8
## 4 D 20
pie(simpan$Jumlah,labels = simpan$Produk, main = "Data Penjualan Produk A, B, C, dan D")

pie(simpan$Jumlah,labels = simpan$Produk, main = "Data Penjualan Produk A, B, C, dan D", col = heat.colors(4))

pie(simpan$Jumlah,labels = simpan$Jumlah, main = "Data penjualan Produk A, B, C, dan D", col = heat.colors(4))
colors=heat.colors(4)
legend(1,0.5, c("Produ A", "Produk B", "Produk C", "Produk D"), cex=0.8, fill=colors)

pie(simpan$Jumlah,labels = simpan$Jumlah, main = "Data Penjualan Produk A, B, C, dan D",
col = c("darkblue", "orange", "yellow", "red"))
colors=c("darkblue", "orange", "yellow", "red")
legend(1,0.5, c("Produk A", "Produk B", "Produk C", "Produk D"), cex=0.8, fill=colors)

Persen=round(simpan$Jumlah/sum(simpan$Jumlah)*100,4)
Persen=paste(Persen,"%", sep="")
pie(simpan$Jumlah,labels=Persen, main = "Data penjualan Produk A, B, C, dan D",
col=c("darkblue", "orange", "yellow", "red"))
colors=c("darkblue", "orange", "yellow", "red")
legend(1,0.5, c("Produk A", "Produk B", "Produk C", "Produk D"), cex=0.8, fill=colors)

Persen=round(simpan$Jumlah/sum(simpan$Jumlah)*100,4)
Persen=paste(Persen,"%", sep="")
pie(simpan$Jumlah,labels=Persen, main = "Data penjualan Produk A, B, C, dan D",
col=c("darkblue", "orange", "yellow", "red"))
colors=c("darkblue", "orange", "yellow", "red")
legend(1,0.5, c("Produk A", "Produk B", "Produk C", "Produk D"), cex=0.8, fill=colors)

Jumlah=simpan$Jumlah
Produk=simpan$Produk
library(ggplot2)
pie = ggplot(simpan, aes(x="", y=Jumlah, fill=Produk)) + geom_bar(width = 1, stat = "identity") + coord_polar("y", start = 0)
pie

library(ggplot2)
library(grid)
library(gridExtra)
blan_theme = theme(
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size = 14, face = "bold")
)
library(scales)
pie + blan_theme + geom_text(aes(y=Jumlah/4 + c(0,cumsum(Jumlah)[-length(Jumlah)]), label=Jumlah), size=5)

pie + blan_theme + geom_text(aes(y=Jumlah/4 + c(0,cumsum(Jumlah)[-length(Jumlah)]), label=Jumlah), size=5) +
scale_fill_manual(values = c(heat.colors(4)))

Persen=round(simpan$Jumlah/sum(simpan$Jumlah)*100,2)
Persen=paste(Persen,"%", sep="")
pie + blan_theme + geom_text(aes(y=Jumlah/4 + c(0,cumsum(Jumlah)[-length(Jumlah)]),
label=Persen), size=5) +
scale_fill_manual(values = c(heat.colors(4)))
