Line Plotting: Visualizing Trends in Narrow Data

Line graphs are visual representations of data points connected by line segments. They effectively showcase trends and changes over time or across different categories. Ideal for displaying continuous data, line graphs highlight patterns and correlations, making complex information easily digestible. Creating effective line graphs involves careful consideration of axis labels, scales, and legends. Clear and concise titles are essential for quick understanding. Multiple datasets can be compared on a single graph, enhancing visual analysis and facilitating insightful conclusions.


Economist GGPlot Excel Paul Tol Black And White Solarized Stata Tableau Wall Street CanvasXpress
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Use a data frame (2D-array) for the graph
      var data = [
        [ "Id", "Days Old", "Circumference (mm)", "Tree"],
        [ 1, 118, 30, "Tree-1"],
        [ 2, 484, 58, "Tree-1"],
        [ 3, 664, 87, "Tree-1"],
        [ 4, 1004, 115, "Tree-1"],
        [ 5, 1231, 120, "Tree-1"],
        [ 6, 1372, 142, "Tree-1"],
        [ 7, 1582, 145, "Tree-1"],
        [ 8, 118, 33, "Tree-2"],
        [ 9, 484, 69, "Tree-2"],
        [ 10, 664, 111, "Tree-2"],
        [ 11, 1004, 156, "Tree-2"],
        [ 12, 1231, 172, "Tree-2"],
        [ 13, 1372, 203, "Tree-2"],
        [ 14, 1582, 203, "Tree-2"],
        [ 15, 118, 30, "Tree-3"],
        [ 16, 484, 51, "Tree-3"],
        [ 17, 664, 75, "Tree-3"],
        [ 18, 1004, 108, "Tree-3"],
        [ 19, 1231, 115, "Tree-3"],
        [ 20, 1372, 139, "Tree-3"],
        [ 21, 1582, 140, "Tree-3"],
        [ 22, 118, 32, "Tree-4"],
        [ 23, 484, 62, "Tree-4"],
        [ 24, 664, 112, "Tree-4"],
        [ 25, 1004, 167, "Tree-4"],
        [ 26, 1231, 179, "Tree-4"],
        [ 27, 1372, 209, "Tree-4"],
        [ 28, 1582, 214, "Tree-4"],
        // ... (data truncated after 29 records for clarity)
      ]

      // Create the configuration for the graph
      var config = {
         "colorBy" : "Tree",
         "graphOrientation" : "horizontal",
         "graphType" : "Scatter2D",
         "lineBy" : "Tree",
         "showLegend" : false,
         "title" : "Growth of Orange Trees",
         "xAxis" : ["Days Old"],
         "yAxis" : ["Circumference (mm)"]
      }

      // Event used to create graph (optional)
      var events = false


      // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

      
    </script>

  </body>

</html>
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Create the data for the graph
      var data = {
         "y" : {
            "data" : [
              [118,30],
              [484,58],
              [664,87],
              [1004,115],
              [1231,120],
              [1372,142],
              [1582,145],
              [118,33],
              [484,69],
              [664,111],
              [1004,156],
              [1231,172],
              [1372,203],
              [1582,203],
              [118,30],
              [484,51],
              [664,75],
              [1004,108],
              [1231,115],
              [1372,139],
              [1582,140],
              [118,32],
              [484,62],
              [664,112],
              [1004,167],
              [1231,179],
              [1372,209],
              [1582,214],
              [118,30],
              [484,49],
              [664,81],
              [1004,125],
              [1231,142],
              [1372,174],
              [1582,177]
            ],
            "smps" : ["Days Old","Circumference (mm)"],
            "vars" : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]
         },
         "z" : {
            "Tree" : ["Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5"]
         }
      }

      // Create the configuration for the graph
      var config = {
         "colorBy" : "Tree",
         "graphOrientation" : "horizontal",
         "graphType" : "Scatter2D",
         "lineBy" : "Tree",
         "showLegend" : false,
         "title" : "Growth of Orange Trees",
         "xAxis" : ["Days Old"],
         "yAxis" : ["Circumference (mm)"]
      }

      // Event used to create graph (optional)
      var events = false


      // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

      
    </script>

  </body>

</html>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-oranges2-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
z=read.table("https://www.canvasxpress.org/data/r/cX-oranges2-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  varAnnot=z,
  colorBy="Tree",
  graphOrientation="horizontal",
  graphType="Scatter2D",
  lineBy="Tree",
  showLegend=FALSE,
  title="Growth of Orange Trees",
  xAxis=list("Days Old"),
  yAxis=list("Circumference (mm)")
)