Visualize Data with Spider Plots
Scatter2D graphs are a fundamental visualization tool used to display the relationship between two numerical variables. Each data point is represented as a dot on a two-dimensional plane, where the x-coordinate and y-coordinate correspond to the values of the two variables. This allows for quick identification of trends, clusters, and outliers in the data. Applications range from scientific data analysis to business intelligence, making them highly versatile. Creating effective Scatter2D graphs involves careful consideration of axis scaling, labeling, and color-coding. Highlighting specific data points or regions can improve understanding. Interactive Scatter2D plots further enhance exploration, allowing users to zoom, pan, and select individual data points for detailed examination. Choosing appropriate visualization tools greatly impacts the ability to draw meaningful insights from data.
<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", "Weeks", "Change From Baseline %", "Response", "Subject"],
        [ "Var1", 0, 0, "Complete Response", "S101810"],
        [ "Var2", 8, -0.6, "Complete Response", "S101810"],
        [ "Var3", 16, -0.7, "Complete Response", "S101810"],
        [ "Var4", 24, -0.7, "Complete Response", "S101810"],
        [ "Var5", 32, -0.7, "Complete Response", "S101810"],
        [ "Var6", 40, -0.7, "Complete Response", "S101810"],
        [ "Var7", 48, -0.65, "Complete Response", "S101810"],
        [ "Var8", 56, -0.7, "Complete Response", "S101810"],
        [ "Var9", 0, 0, "Progressive Disease", "S103101"],
        [ "Var10", 8, 0.5, "Progressive Disease", "S103101"],
        [ "Var11", 16, 0.7, "Progressive Disease", "S103101"],
        [ "Var12", 0, 0, "Progressive Disease", "S103105"],
        [ "Var13", 8, 0.3, "Progressive Disease", "S103105"],
        [ "Var14", 16, 0.4, "Progressive Disease", "S103105"],
        [ "Var15", 24, 0.6, "Progressive Disease", "S103105"],
        [ "Var16", 0, 0, "Partial Response", "S103201"],
        [ "Var17", 8, -0.1, "Partial Response", "S103201"],
        [ "Var18", 16, -0.3, "Partial Response", "S103201"],
        [ "Var19", 24, -0.2, "Partial Response", "S103201"],
        [ "Var20", 32, -0.4, "Partial Response", "S103201"],
        [ "Var21", 40, -0.5, "Partial Response", "S103201"],
        [ "Var22", 0, 0, "Partial Response", "S103205"],
        [ "Var23", 8, -0.4, "Partial Response", "S103205"],
        [ "Var24", 16, -0.5, "Partial Response", "S103205"],
        [ "Var25", 24, -0.55, "Partial Response", "S103205"],
        [ "Var26", 32, -0.55, "Partial Response", "S103205"],
        [ "Var27", 40, -0.4, "Partial Response", "S103205"],
        [ "Var28", 48, -0.7, "Partial Response", "S103205"],
        // ... (data truncated after 29 records for clarity)
      ]
      // Create the configuration for the graph
      var config = {
        "colorBy": "Response",
        "graphType": "Scatter2D",
        "legendBox": true,
        "legendInside": true,
        "legendPosition": "topRight",
        "lineBy": "Subject",
        "title": "Tumor Response by Week",
        "xAxis": ["Weeks"],
        "yAxis": ["Change From Baseline %"]
      }
      // 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" : [
              [0,0],
              [8,-0.6],
              [16,-0.7],
              [24,-0.7],
              [32,-0.7],
              [40,-0.7],
              [48,-0.65],
              [56,-0.7],
              [0,0],
              [8,0.5],
              [16,0.7],
              [0,0],
              [8,0.3],
              [16,0.4],
              [24,0.6],
              [0,0],
              [8,-0.1],
              [16,-0.3],
              [24,-0.2],
              [32,-0.4],
              [40,-0.5],
              [0,0],
              [8,-0.4],
              [16,-0.5],
              [24,-0.55],
              [32,-0.55],
              [40,-0.4],
              [48,-0.7],
              [58,-0.8]
            ],
            "smps" : ["Weeks","Change From Baseline %"]
         },
         "z" : {
            "Response" : ["Complete Response","Complete Response","Complete Response","Complete Response","Complete Response","Complete Response","Complete Response","Complete Response","Progressive Disease","Progressive Disease","Progressive Disease","Progressive Disease","Progressive Disease","Progressive Disease","Progressive Disease","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response","Partial Response"],
            "Subject" : ["S101810","S101810","S101810","S101810","S101810","S101810","S101810","S101810","S103101","S103101","S103101","S103105","S103105","S103105","S103105","S103201","S103201","S103201","S103201","S103201","S103201","S103205","S103205","S103205","S103205","S103205","S103205","S103205","S103205"]
         }
      }
      // Create the configuration for the graph
      var config = {
        "colorBy": "Response",
        "graphType": "Scatter2D",
        "legendBox": true,
        "legendInside": true,
        "legendPosition": "topRight",
        "lineBy": "Subject",
        "title": "Tumor Response by Week",
        "xAxis": ["Weeks"],
        "yAxis": ["Change From Baseline %"]
      }
      // 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-spider-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-spider-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  varAnnot=z,
  colorBy="Response",
  graphType="Scatter2D",
  legendBox=TRUE,
  legendInside=TRUE,
  legendPosition="topRight",
  lineBy="Subject",
  title="Tumor Response by Week",
  xAxis=list("Weeks"),
  yAxis=list("Change From Baseline %")
)
                    
















