Visualize Data with Scatter2D Graphs

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.


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", "Alcohol", "Tobacco"],
        [ "North", 6.47, 4.03],
        [ "Yorkshire", 6.13, 3.76],
        [ "Northeast", 6.19, 3.77],
        [ "East Midlands", 4.89, 3.34],
        [ "West Midlands", 5.63, 3.47],
        [ "East Anglia", 4.52, 2.92],
        [ "Southeast", 5.89, 3.2],
        [ "Southwest", 4.79, 2.71],
        [ "Wales", 3.53, 3.53],
        [ "Scotland", 6.08, 4.51],
        [ "Northern Ireland", 4.02, 4.56 ]
      ];

      // Create the configuration for the graph
      var config = {
        "citation": "Moore, David S., and George P. McCabe (1989). Introduction to the Practice of Statistics, p. 179.",
        "decorations": {
          "marker": [
            {
              "sample": ["Alcohol", "Tobacco"],
              "text": "Maybe an Outlier?",
              "variable": "Northern Ireland",
              "x": 0.45,
              "y": 0.18
            }
          ]
        },
        "graphType": "Scatter2D",
        "showTransition": false,
        "title": "Average weekly household spending, in British pounds, on tobacco products\\nand alcoholic beverages for each of the 11 regions of Great Britain.",
        "xAxis": ["Alcohol"],
        "yAxis": ["Tobacco"]
      }

      // 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" : [
              [6.47,4.03],
              [6.13,3.76],
              [6.19,3.77],
              [4.89,3.34],
              [5.63,3.47],
              [4.52,2.92],
              [5.89,3.2],
              [4.79,2.71],
              [3.53,3.53],
              [6.08,4.51],
              [4.02,4.56]
            ],
            "smps" : ["Alcohol","Tobacco"],
            "vars" : ["North","Yorkshire","Northeast","East Midlands","West Midlands","East Anglia","Southeast","Southwest","Wales","Scotland","Northern Ireland"]
         }
      }

      // Create the configuration for the graph
      var config = {
        "citation": "Moore, David S., and George P. McCabe (1989). Introduction to the Practice of Statistics, p. 179.",
        "decorations": {
          "marker": [
            {
              "sample": ["Alcohol", "Tobacco"],
              "text": "Maybe an Outlier?",
              "variable": "Northern Ireland",
              "x": 0.45,
              "y": 0.18
            }
          ]
        },
        "graphType": "Scatter2D",
        "showTransition": false,
        "title": "Average weekly household spending, in British pounds, on tobacco products\\nand alcoholic beverages for each of the 11 regions of Great Britain.",
        "xAxis": ["Alcohol"],
        "yAxis": ["Tobacco"]
      }

      // 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-alcoholtobaccot-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  citation="Moore, David S., and George P. McCabe (1989). Introduction to the Practice of Statistics, p. 179.",
  decorations=list(marker=list(list(sample=list("Alcohol", "Tobacco"), text="Maybe an Outlier?", variable="Northern Ireland", x=0.45, y=0.18))),
  graphType="Scatter2D",
  showTransition=FALSE,
  title="Average weekly household spending, in British pounds, on tobacco products\nand alcoholic beverages for each of the 11 regions of Great Britain.",
  xAxis=list("Alcohol"),
  yAxis=list("Tobacco")
)