Page 261 - Data Science class 11
P. 261

Example
            The below script will create and save a line chart in the current R working directory.

                # Adding the rainfall data for six consequetive months.
                v <- c(30,   29, 54, 217, 248, 134)
                # Giving the chart file a name.
                png(file = "line_chart_label_colored1.jpg")
                # Plot the bar chart.
                  plot(v,type = "o", col = "red", xlab = "Month Starting Apr.", ylab = "Rainfall in
                mm",
                   main = "Rainfall Delhi")
                # Save the file.
                dev.off()
            When we execute the above code, it produces the following result:















































                                                Line Chart Labeled with Title in R


            7.6.2 Multiple lines in a line chart
            More than one line can be drawn on the same chart by using the lines() function.

            After the first line is plotted, the lines() function can use an additional vector as input to draw the second line in the chart.

                # Comparing Rainfall in Delhi and Ahmedabad by line chart.
                v <- c(30,   29, 54, 217, 248, 134)

                                                           Coding for Data Science Visualisation using R-Studio  259
   256   257   258   259   260   261   262   263   264   265   266