Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement Area Chart using ggplot2 in R?

Description

To implement the area chart using ggplot2 in R programming.

Process

Package and Function:

   R Package : ggplot2

   R Function :ggplot(x, aes(x= , y= ), fill= )

   R Function : geom_area(colour =)

x - Data Set

aes- Aesthetic mappings describe

   how variables in the data are mapped to visual properties (aesthetics) of geoms.

   Aesthetic mappings can be set in ggplot2() and in individual layers.

Sapmle Code

#Area Chart Using ggplot2

#Loading required Packages

#install.packages(“ggplot2”)

library(“ggplot2”)

 

#Input

#install.packages(“xlsx”)

library(“xlsx”)

input<-read.xlsx(“OnlineShopping.xlsx”,sheetIndex = 1)

print(head(input))

 

#Area Chart

ggplot(input,aes(x=income,y=age,fill=commodity)) + geom_area()

ggplot(input,aes(x=income,y=age,fill=commodity)) + geom_area(colour=”Black”)

Screenshots
implement Area Chart using ggplot2 in R
Area Chart Using ggplot2
Loading required Packages