Smooth Data Contour Plot

Contour graphs, also known as contour plots, are visual representations of three-dimensional (3D) surfaces in two dimensions (2D). They are useful for depicting functions of two variables, showing regions of constant value. These graphs use lines, called contour lines or isolines, to connect points of equal value on the surface. Applications span diverse fields like geography (topographic maps), meteorology (weather maps showing isobars), and engineering (design optimization). Understanding contour graphs enhances data interpretation and analysis across various disciplines.


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", "s1", "s2", "s3", "s4", "s5", "s6", "s7"],
        [ "v1", 16, 17, 18, 19, 19, 21, 22],
        [ "v2", 15, 16, 17, 18, 20, 21, 23],
        [ "v3", 14, 13, 14, 15, 18, 21, 24],
        [ "v4", 13, 12, 11, 13, 16, 23, 25],
        [ "v5", 12, 11, 7, 8, 9, 27, 26],
        [ "v6", 7, 6, 7, 8, 10, 5, 17],
        [ "v7", 4, 1, 2, 3, 4, 10, 14],
        [ "v8", 2, 3, 4, 5, 7, 9, 11 ]
      ];

      // Create the configuration for the graph
      var config = {
         "contourType" : "normal",
         "graphType" : "Heatmap",
         "heatmapCellBox" : false,
         "lineType" : "spline",
         "showContourLevel" : false,
         "showSampleNames" : false,
         "showVariableNames" : false,
         "xAxis" : ["v1","v2","v3","v4","v5","v6","v7","v8"]
      }

      // 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);

      // Functions after rendering graph
      cX.createContour();

    </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" : [
              [16,17,18,19,19,21,22],
              [15,16,17,18,20,21,23],
              [14,13,14,15,18,21,24],
              [13,12,11,13,16,23,25],
              [12,11,7,8,9,27,26],
              [7,6,7,8,10,5,17],
              [4,1,2,3,4,10,14],
              [2,3,4,5,7,9,11]
            ],
            "smps" : ["s1","s2","s3","s4","s5","s6","s7"],
            "vars" : ["v1","v2","v3","v4","v5","v6","v7","v8"]
         }
      }

      // Create the configuration for the graph
      var config = {
         "contourType" : "normal",
         "graphType" : "Heatmap",
         "heatmapCellBox" : false,
         "lineType" : "spline",
         "showContourLevel" : false,
         "showSampleNames" : false,
         "showVariableNames" : false,
         "xAxis" : ["v1","v2","v3","v4","v5","v6","v7","v8"]
      }

      // 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);

      // Functions after rendering graph
      cX.createContour();

    </script>

  </body>

</html>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-contour4-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  contourType="normal",
  graphType="Heatmap",
  heatmapCellBox=FALSE,
  lineType="spline",
  showContourLevel=FALSE,
  showSampleNames=FALSE,
  showVariableNames=FALSE,
  xAxis=list("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8"),
  afterRender=list(list("createContour"))
)