Page 260 - Data Science class 11
P. 260

Example
        A simple line chart is created using the input vector and the type parameter as "O". Let's create a rainfall line chart for
        Delhi in six months of effective rain as per data of 2020:

         Month                     Apr           May           June          July          Aug           Sep
         Rainfall in mm             30            29            54           217           248           134

        The below script will create and save a line chart in the current R working directory.
             # Create the data for the chart.
             v <- c(30,   29, 54, 217, 248, 134)
             # Give the chart file a name.
             png(file = "line_chart.jpg")
             # Plot the bar chart.
             plot(v,type = "o")
             # Save the file.
             dev.off()
        When we execute the above code, it produces the following result:















































                                                    Line Chart using R

        7.6.1 line chart with title, colour and labels

        The features of the line chart can be expanded by using additional parameters. You can add colour to the points and
        lines, give a title to the chart, and add labels to the axes.
          258   Touchpad Data Science-XI
   255   256   257   258   259   260   261   262   263   264   265