library (ggplot2)
##Scatter Plot
data(iris)
ggplot(iris, aes(x=Sepal.Length, y=Petal.Length))+geom_point()
##geometry of data
ggplot(iris, aes(x=Sepal.Length, y=Petal.Length, col=Species, shape=Species))+geom_point()
## smooth line
ggplot(iris, aes(x=Sepal.Length, y=Petal.Length, col=Species))+geom_point() +geom_smooth()
ggplot(iris, aes(x=Sepal.Length, y=Petal.Length, col=Species))+geom_point(color = "blue") + geom_smooth(color = "red")
data(mtcars)
ggplot(mtcars, aes(hp, mpg)) + geom_point(color = "blue") + stat_summary(fun.y = "mean", geom = "line", linetype = "dashed")
##histogram
ggplot(mtcars,aes(x=mpg)) + geom_histogram()
##boxplot
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) + geom_boxplot()
##boxplot
mtcars$cyl <- as.factor(mtcars$cyl)
ggplot(mtcars, aes(x=(cyl), y=mpg,color = cyl)) + geom_boxplot()+scale_color_manual(values = c("#3a0ca3", "#c9184a", "#3a5a40"))
##Violin Plot
ggplot(mtcars, aes(factor(cyl), mpg))+ geom_violin(aes(fill = cyl))
##Pie Chart
ggplot(mtcars, aes(x="", y=mpg, fill=cyl)) + geom_bar(stat="identity", width=1) + coord_polar("y", start=0)
To embed this program on your website, copy the following code and paste it into your website's HTML: