Page 262 - Data Science class 11
P. 262
t <- c(24,27.0,80.0,249.2,236.2,86.8)
# Give the chart file a name.
png(file = "line_chart_5_lines.jpg")
# Plot the bar chart.
plot(v,type = "o",col = "red", xlab = "Month starting from Apr", ylab = "Rainfall
in mm",
main = "Rainfall Delhi /Ahmedabad")
lines(t, type = "o", col = "blue")
# Save the file.
dev.off()
When you execute the above code, it produces the following result:
7.6.3 drawing a line chart using the ggplot2
Now let us see how we can draw a line chart using the ggplot2 plotting package.
Here we are plotting a particular country’s world cup win and then connecting them via line chart.
set.seed()—this function is used to generate random values.
Example
Enter the following code snippet into the script panel:
library(ggplot2)
260 Touchpad Data Science-XI

