Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

colors <-c("green", "orange", "brown","pink","yellow")

years <-c("2017", "2018", "2019", "2020", "2021")


regions <- c("Rajasthan", "Madhya Pradesh", "Maharastra","Uttar
Pardesh","Gujarat")
# Create the matrix of the values
Values <- matrix(c(52.12,   58.48,  75.75,  63.4,   70.26,57.6, 60.2,   67.03,
65.1    ,70.6,66.11 ,65.61  ,76.88, 65.7    ,69.68,67.9,    67.43,  77.1,  
66.4,   72.24,
                   69.7 ,69.46, 75.87,  67  ,74.8),
                 nrow = 5, ncol = 5, byrow = TRUE)
# Create the bar chart
barplot(Values, main = "Total Literacy Rate", names.arg = regions,
        xlab = "regions", ylab = "States", col = colors, beside = TRUE)
# Add the legend to the chart
legend("topright", years, cex = 0.4, fill = colors)

# 2nd representation

#pie representation of rajasthan


# Create data for the graph.
dataRajasthan <- c(52.12,57.6,66.11,67.9,69.7)
year = c("2017", "2018", "2019", "2020", "2021")
piepercent<- round(100 * dataRajasthan / sum(dataRajasthan), 1)

# Plot the chart.


pie(dataRajasthan, labels = year,
    main = "Rajasthan Literacy Rate", col = rainbow(length(dataRajasthan)))
legend("topright", c("2017", "2018", "2019", "2020", "2021"),
       cex = 0.5, fill = rainbow(length(dataRajasthan)))

# Pie representation of Madhya Pradesh


dataMp <- c(58.48,60.2, 65.61, 67.43, 69.46)
year = c("2017", "2018", "2019", "2020", "2021")
piepercent<- round(100 * dataMp / sum(dataMp), 1)
# Plot the chart.
pie(dataMp, labels = year,
    main = " Madhya Pradesh Literacy Rate", col = rainbow(length(dataMp)))
legend("topright", c("2017", "2018", "2019", "2020", "2021"),
       cex = 0.5, fill = rainbow(length(dataMp)))

# Pie representation of Maharashtra


dataMh <- c(75.75, 67.03, 76.88, 77.1, 75.87)
year = c("2017", "2018", "2019", "2020", "2021")
piepercent<- round(100 * dataMh / sum(dataMh), 1)

# Plot the chart.


pie(dataMh, labels = year,
    main = " Maharashtra Literacy Rate", col = rainbow(length(dataMh)))
legend("topright", c("2017", "2018", "2019", "2020", "2021"),
       cex = 0.5, fill = rainbow(length(dataMh)))

# Pie representation of Uttar Pradesh


dataUp <- c(63.4 , 65.1 ,65.7 ,66.4 ,67)
year = c("2017", "2018", "2019", "2020", "2021")
piepercent<- round(100 * dataUp / sum(dataUp), 1)

# Plot the chart.


pie(dataUp, labels = year,
    main = " Uttar Pradesh Literacy Rate", col = rainbow(length(dataUp)))
legend("topright", c("2017", "2018", "2019", "2020", "2021"),
       cex = 0.5, fill = rainbow(length(dataUp)))
# Pie representation of Gujarat
dataG <- c(70.26, 70.6 ,69.68 ,72.24 ,74.8)
year = c("2017", "2018", "2019", "2020", "2021")
piepercent<- round(100 * dataG / sum(dataG), 1)

# Plot the chart.


pie(dataG, labels = year,
    main = " Gujarat Literacy Rate", col = rainbow(length(dataG)))
legend("topright", c("2017", "2018", "2019", "2020", "2021"),
       cex = 0.5, fill = rainbow(length(dataG)))

You might also like