#Create the data for the chart.
v <- c(17, 25, 38, 13, 41)
t <- c(22, 19, 36, 19, 23)
m <- c(25, 14, 16, 34, 29)
# Plot the bar chart.
plot(v, type = "o", col = "red",
xlab = "Month", ylab = "Article Written ",
main = "Article Written chart")
lines(t, type = "o", col = "blue")
lines(m, type = "o", col = "green")
#Create the data for the chart
A <- c(17, 32, 8, 53, 1)
# Plot the bar chart
barplot(A, xlab = "X-axis", ylab = "Y-axis", main ="Bar-Chart")
# Create the data for the chart
A <- c(17, 32, 8, 53, 1)
# Plot the bar chart
barplot(A, horiz = TRUE, xlab = "X-axis",
ylab = "Y-axis", main ="Bar-Chart")
# Create the data for the chart
A <- c(17, 2, 8, 13, 1, 22)
B <- c("Jan", "feb", "Mar", "Apr", "May", "Jun")
# Plot the bar chart
barplot(A, names.arg = B, xlab ="Month",
ylab ="Articles", col ="green",
main ="GeeksforGeeks-Article chart")
#Creating Stacked and Grouped Bar Chart Program:
colors <-c("green", "orange", "brown")
months <- c("Mar", "Apr", "May", "Jun", "Jul")
regions <- c("East", "West", "North")
# Create the matrix of the values.
Values <- matrix(c(2, 9, 3, 11, 9, 4, 8, 7, 3, 12, 5, 2, 8, 10, 11),
nrow = 3, ncol = 5, byrow = TRUE)
# Create the bar chart
barplot(Values, main = "Total Revenue", names.arg = months,
xlab = "Month", ylab = "Revenue",
col = colors, beside = TRUE)
# Add the legend to the chart
legend("topleft", regions, cex = 0.7, fill = colors)
#Program2
colors = c("green", "orange", "brown")
months <- c("Mar", "Apr", "May", "Jun", "Jul")
regions <- c("East", "West", "North")
# Create the matrix of the values.
Values <- matrix(c(2, 9, 3, 11, 9, 4, 8, 7, 3, 12, 5, 2, 8, 10, 11),
nrow = 3, ncol = 5, byrow = TRUE)
# Create the bar chart
barplot(Values, main = "Total Revenue", names.arg = months,
xlab = "Month", ylab = "Revenue", col = colors)
# Add the legend to the chart
legend("topleft", regions, cex = 0.7, fill = colors)
#Adding Colors to Charts Program:
# Creating a list
temp<-c(5, 10, 15, 20, 25)
# Barplot with default color
barplot(temp, main ="By default")
# Barplot with green color
barplot(temp, col ="green",
main ="With coloring")
##Color Palette The five inbuilt color palettes are provided in the R language for generating color vector easily and faster. They are:
#rainbow()
#terrain.colors()
#heat.colors()
#cm.colors()
#topo.colors()
# Create data for the graph.
geeks<- c(23, 56, 20, 63)
labels <- c("Mumbai", "Pune", "Chennai", "Bangalore")
# Plot the chart.
pie(geeks, labels)
#with title Program:
# Create data for the graph.
geeks<- c(23, 56, 20, 63)
labels <- c("Mumbai", "Pune", "Chennai", "Bangalore")
# Plot the chart with title and rainbow color pallet.
pie(geeks, labels, main = "City pie chart",
col = rainbow(length(geeks)))
To embed this program on your website, copy the following code and paste it into your website's HTML: