Contour plots are graphs to show a three-dimensional surface on a two-dimensional plane. It graphs the X, Y variables on the plane axis and a response variable Z as contours. The format of the data can be specified as a three column x, y, z (long and skiny) data set or as rows and columns (short and fat) specifying the z value.
<!-- 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/canvasXpress.min.js"></script> <!-- 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,10], [1,0,5.625], [2,0,2.5], [3,0,0.625], [4,0,0], [0,1,10.625], [1,1,6.25], [2,1,3.125], [3,1,1.25], [4,1,0.625], [0,2,12.5], [1,2,8.125], [2,2,5], [3,2,3.125], [4,2,2.5], [0,3,15.625], [1,3,11.25], [2,3,8.125], [3,3,6.25], [4,3,5.625], [0,4,20], [1,4,15.625], [2,4,12.5], [3,4,10.625], [4,4,10] ], "smps" : ["s1","s2","s3"], "vars" : ["v1","v2","v3","v4","v5","v6","v7","v8","v9","v10","v11","v12","v13","v14","v15","v16","v17","v18","v19","v20","v21","v22","v23","v24","v25"] } } <-- Create the configuration for the graph --> var config = { "contourFilled":"true", "graphType":"ScatterBubble2D", "showContourLevel":"true", "title":"Basic Contour Plot" } <!-- Call the CanvasXpress function to create the graph --> var cX = new CanvasXpress("canvasId", data, config); <-- Functions after rendering graph --> cX.createContour(); </script>
library(canvasXpress) y=read.table("https://www.canvasxpress.org/data/cX-contour2-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE) canvasXpress( data=y, contourFilled=TRUE, graphType="ScatterBubble2D", showContourLevel=TRUE, title="Basic Contour Plot", afterRender=list(list("createContour")) )