Log-scale bubbles with a trend line

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 = 

      // Create the configuration for the graph
      var config = {
         "graphType" : "Scatter2D",
         "titleAlign" : "plot::0",
         "subtitleAlign" : "plot::0",
         "legendHorizontalJustification" : 0,
         "legendJustifyTo" : "plot",
         "sizeScale" : "area",
         "sizeMax" : 40,
         "showSizeLegend" : false,
         "theme" : "classic",
         "xAxisGridMajorShow" : true,
         "yAxisGridMajorShow" : true,
         "title" : "Large and herbivorous mammals have slow hearts",
         "subtitle" : "Resting heart rate vs body mass in mammals (bubble size = lifespan)",
         "xAxis" : [
            "Body mass (kg)"
         ],
         "yAxis" : [
            "Resting heart rate (bpm)"
         ],
         "sizeBy" : "Lifespan (years)",
         "colorBy" : "Diet",
         "colorScheme" : "User",
         "colors" : [
            "rgba(26,152,103,0.7)",
            "rgba(150,150,150,0.55)"
         ],
         "xAxisTransform" : "log10",
         "xAxisTransformTicks" : true,
         "setMinX" : -3,
         "setMaxX" : 4.3,
         "setMinY" : 0,
         "setMaxY" : 900,
         "showLegend" : true,
         "legendPosition" : "top",
         "legendColumns" : 2,
         "xAxisTitle" : "Body weight (kg), logarithmic scale",
         "yAxisTitle" : "Resting heart rate (beats per minute)",
         "showDecorations" : true,
         "decorations" : {
            "marker" : [
               {
                  "type" : "text",
                  "variable" : "Etruscan shrew",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Shrews",
                  "offsetX" : 14,
                  "offsetY" : 0,
                  "align" : "left"
               },
               {
                  "type" : "text",
                  "variable" : "House mouse",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Small rodents",
                  "offsetX" : 14,
                  "offsetY" : 0,
                  "align" : "left"
               },
               {
                  "type" : "text",
                  "variable" : "Human",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Humans",
                  "offsetX" : 22,
                  "offsetY" : -22,
                  "align" : "left",
                  "fontStyle" : "bold"
               },
               {
                  "type" : "text",
                  "variable" : "African elephant",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Elephants",
                  "offsetX" : 8,
                  "offsetY" : -30,
                  "align" : "center"
               },
               {
                  "type" : "text",
                  "variable" : "Horse",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Livestock",
                  "offsetX" : 0,
                  "offsetY" : 26,
                  "align" : "center"
               },
               {
                  "type" : "text",
                  "variable" : "Blue whale",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Whales",
                  "offsetX" : -24,
                  "offsetY" : -24,
                  "align" : "right"
               }
            ]
         }
      }

      // 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" : {
            "vars" : [
               "Etruscan shrew",
               "House mouse",
               "Human",
               "Horse",
               "African elephant",
               "Blue whale",
               "Species 1",
               "Species 2",
               "Species 3",
               "Species 4",
               "Species 5",
               "Species 6",
               "Species 7",
               "Species 8",
               "Species 9",
               "Species 10",
               "Species 11",
               "Species 12",
               "Species 13",
               "Species 14",
               "Species 15",
               "Species 16",
               "Species 17",
               "Species 18",
               "Species 19",
               "Species 20",
               "Species 21",
               "Species 22",
               "Species 23",
               "Species 24",
               "Species 25",
               "Species 26",
               "Species 27",
               "Species 28",
               "Species 29",
               "Species 30",
               "Species 31",
               "Species 32",
               "Species 33",
               "Species 34",
               "Species 35",
               "Species 36",
               "Species 37",
               "Species 38",
               "Species 39",
               "Species 40",
               "Species 41",
               "Species 42",
               "Species 43",
               "Species 44",
               "Species 45",
               "Species 46"
            ],
            "smps" : [
               "Body mass (kg)",
               "Resting heart rate (bpm)",
               "Lifespan (years)"
            ],
            "data" : [
               [
                  0.01,
                  720,
                  2
               ],
               [
                  0.025,
                  560,
                  3
               ],
               [
                  70,
                  70,
                  80
               ],
               [
                  500,
                  38,
                  28
               ],
               [
                  4500,
                  30,
                  65
               ],
               [
                  3000,
                  9,
                  80
               ],
               [
                  11.43,
                  154.84,
                  5.67
               ],
               [
                  0.08,
                  418.21,
                  2.85
               ],
               [
                  3.98,
                  203.11,
                  4.89
               ],
               [
                  3.02,
                  194.09,
                  3.98
               ],
               [
                  3.91,
                  218.31,
                  4.01
               ],
               [
                  0.57,
                  307.85,
                  4.53
               ],
               [
                  165.1,
                  85.51,
                  12.15
               ],
               [
                  560.45,
                  74.62,
                  19.29
               ],
               [
                  9.69,
                  174.72,
                  7.44
               ],
               [
                  52.54,
                  95.74,
                  8.49
               ],
               [
                  6.77,
                  225.3,
                  5.98
               ],
               [
                  1,
                  259.51,
                  5.69
               ],
               [
                  44.79,
                  142.11,
                  11.81
               ],
               [
                  581.52,
                  71.09,
                  11.28
               ],
               [
                  1.09,
                  315.71,
                  2.94
               ],
               [
                  0.13,
                  416.93,
                  3.35
               ],
               [
                  19.88,
                  168.05,
                  5.95
               ],
               [
                  23.22,
                  168.19,
                  9.46
               ],
               [
                  112.9,
                  127.16,
                  9.96
               ],
               [
                  1341.46,
                  67.07,
                  14.81
               ],
               [
                  66.08,
                  109.66,
                  8.53
               ],
               [
                  0.09,
                  410.8,
                  2.87
               ],
               [
                  179.07,
                  69.48,
                  10.4
               ],
               [
                  43.99,
                  83.53,
                  10.08
               ],
               [
                  0.07,
                  629.83,
                  2.58
               ],
               [
                  1239.37,
                  68.84,
                  13.6
               ],
               [
                  3.86,
                  242.87,
                  5.04
               ],
               [
                  3.86,
                  196.87,
                  4.38
               ],
               [
                  2379.74,
                  49.58,
                  17.32
               ],
               [
                  20.52,
                  171.25,
                  9.01
               ],
               [
                  0.15,
                  419.8,
                  2.71
               ],
               [
                  364.75,
                  107.09,
                  18.14
               ],
               [
                  1.64,
                  307.71,
                  3.69
               ],
               [
                  191.36,
                  90.87,
                  12.92
               ],
               [
                  0.16,
                  456.05,
                  2.88
               ],
               [
                  12.56,
                  178.87,
                  6.61
               ],
               [
                  2593.34,
                  68.81,
                  21.23
               ],
               [
                  2.78,
                  198.95,
                  7.17
               ],
               [
                  0.09,
                  437.44,
                  3.64
               ],
               [
                  0.08,
                  463.07,
                  1.89
               ],
               [
                  0.16,
                  453.56,
                  2.15
               ],
               [
                  2917.84,
                  48.47,
                  13.08
               ],
               [
                  1686.19,
                  52.74,
                  18.43
               ],
               [
                  45.97,
                  172.18,
                  9.6
               ],
               [
                  4.57,
                  193.13,
                  4.62
               ],
               [
                  194.33,
                  95.38,
                  16.74
               ]
            ]
         },
         "z" : {
            "Diet" : [
               "Other",
               "Other",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Herbivore",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Herbivore",
               "Other",
               "Other",
               "Herbivore",
               "Other",
               "Other",
               "Other",
               "Other",
               "Herbivore",
               "Herbivore",
               "Herbivore",
               "Herbivore",
               "Herbivore",
               "Other",
               "Herbivore",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Other",
               "Other",
               "Other",
               "Other",
               "Herbivore",
               "Herbivore",
               "Herbivore",
               "Other",
               "Herbivore",
               "Other",
               "Herbivore",
               "Herbivore",
               "Other",
               "Other",
               "Other"
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "Scatter2D",
         "titleAlign" : "plot::0",
         "subtitleAlign" : "plot::0",
         "legendHorizontalJustification" : 0,
         "legendJustifyTo" : "plot",
         "sizeScale" : "area",
         "sizeMax" : 40,
         "showSizeLegend" : false,
         "theme" : "classic",
         "xAxisGridMajorShow" : true,
         "yAxisGridMajorShow" : true,
         "title" : "Large and herbivorous mammals have slow hearts",
         "subtitle" : "Resting heart rate vs body mass in mammals (bubble size = lifespan)",
         "xAxis" : [
            "Body mass (kg)"
         ],
         "yAxis" : [
            "Resting heart rate (bpm)"
         ],
         "sizeBy" : "Lifespan (years)",
         "colorBy" : "Diet",
         "colorScheme" : "User",
         "colors" : [
            "rgba(26,152,103,0.7)",
            "rgba(150,150,150,0.55)"
         ],
         "xAxisTransform" : "log10",
         "xAxisTransformTicks" : true,
         "setMinX" : -3,
         "setMaxX" : 4.3,
         "setMinY" : 0,
         "setMaxY" : 900,
         "showLegend" : true,
         "legendPosition" : "top",
         "legendColumns" : 2,
         "xAxisTitle" : "Body weight (kg), logarithmic scale",
         "yAxisTitle" : "Resting heart rate (beats per minute)",
         "showDecorations" : true,
         "decorations" : {
            "marker" : [
               {
                  "type" : "text",
                  "variable" : "Etruscan shrew",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Shrews",
                  "offsetX" : 14,
                  "offsetY" : 0,
                  "align" : "left"
               },
               {
                  "type" : "text",
                  "variable" : "House mouse",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Small rodents",
                  "offsetX" : 14,
                  "offsetY" : 0,
                  "align" : "left"
               },
               {
                  "type" : "text",
                  "variable" : "Human",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Humans",
                  "offsetX" : 22,
                  "offsetY" : -22,
                  "align" : "left",
                  "fontStyle" : "bold"
               },
               {
                  "type" : "text",
                  "variable" : "African elephant",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Elephants",
                  "offsetX" : 8,
                  "offsetY" : -30,
                  "align" : "center"
               },
               {
                  "type" : "text",
                  "variable" : "Horse",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Livestock",
                  "offsetX" : 0,
                  "offsetY" : 26,
                  "align" : "center"
               },
               {
                  "type" : "text",
                  "variable" : "Blue whale",
                  "sample" : [
                     "Body mass (kg)",
                     "Resting heart rate (bpm)"
                  ],
                  "text" : "Whales",
                  "offsetX" : -24,
                  "offsetY" : -24,
                  "align" : "right"
               }
            ]
         }
      }

      // 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-scatter2d28-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-scatter2d28-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
varAnnot=z,
colorBy="Diet",
colorScheme="User",
colors=list("rgba(26,152,103,0.7)", "rgba(150,150,150,0.55)"),
decorations=list(marker=list(list(align="left", offsetX=14, offsetY=0, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Shrews", type="text", variable="Etruscan shrew"), list(align="left", offsetX=14, offsetY=0, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Small rodents", type="text", variable="House mouse"), list(align="left", fontStyle="bold", offsetX=22, offsetY=-22, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Humans", type="text", variable="Human"), list(align="center", offsetX=8, offsetY=-30, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Elephants", type="text", variable="African elephant"), list(align="center", offsetX=0, offsetY=26, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Livestock", type="text", variable="Horse"), list(align="right", offsetX=-24, offsetY=-24, sample=list("Body mass (kg)", "Resting heart rate (bpm)"), text="Whales", type="text", variable="Blue whale"))),
graphType="Scatter2D",
legendColumns=2,
legendHorizontalJustification=0,
legendJustifyTo="plot",
legendPosition="top",
setMaxX=4.3,
setMaxY=900,
setMinX=-3,
setMinY=0,
showDecorations=TRUE,
showLegend=TRUE,
showSizeLegend=FALSE,
sizeBy="Lifespan (years)",
sizeMax=40,
sizeScale="area",
subtitle="Resting heart rate vs body mass in mammals (bubble size = lifespan)",
subtitleAlign="plot::0",
theme="classic",
title="Large and herbivorous mammals have slow hearts",
titleAlign="plot::0",
xAxis=list("Body mass (kg)"),
xAxisGridMajorShow=TRUE,
xAxisTitle="Body weight (kg), logarithmic scale",
xAxisTransform="log10",
xAxisTransformTicks=TRUE,
yAxis=list("Resting heart rate (bpm)"),
yAxisGridMajorShow=TRUE,
yAxisTitle="Resting heart rate (beats per minute)"
)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import show_in_browser

if __name__ == "__main__":
  # Define the chart with its data and configuration
  chart: CanvasXpress = CanvasXpress(
    render_to = "scatter2d28",
    data = {
      "y": {
        "vars": ["Etruscan shrew", "House mouse", "Human", "Horse", "African elephant", "Blue whale", "Species 1", "Species 2", "Species 3", "Species 4", "Species 5", "Species 6", "Species 7", "Species 8", "Species 9", "Species 10", "Species 11", "Species 12", "Species 13", "Species 14", "Species 15", "Species 16", "Species 17", "Species 18", "Species 19", "Species 20", "Species 21", "Species 22", "Species 23", "Species 24", "Species 25", "Species 26", "Species 27", "Species 28", "Species 29", "Species 30", "Species 31", "Species 32", "Species 33", "Species 34", "Species 35", "Species 36", "Species 37", "Species 38", "Species 39", "Species 40", "Species 41", "Species 42", "Species 43", "Species 44", "Species 45", "Species 46"],
        "smps": ["Body mass (kg)", "Resting heart rate (bpm)", "Lifespan (years)"],
        "data": [
          [0.01, 720, 2],
          [0.025, 560, 3],
          [70, 70, 80],
          [500, 38, 28],
          [4500, 30, 65],
          [3000, 9, 80],
          [11.43, 154.84, 5.67],
          [0.08, 418.21, 2.85],
          [3.98, 203.11, 4.89],
          [3.02, 194.09, 3.98],
          [3.91, 218.31, 4.01],
          [0.57, 307.85, 4.53],
          [165.1, 85.51, 12.15],
          [560.45, 74.62, 19.29],
          [9.69, 174.72, 7.44],
          [52.54, 95.74, 8.49],
          [6.77, 225.3, 5.98],
          [1, 259.51, 5.69],
          [44.79, 142.11, 11.81],
          [581.52, 71.09, 11.28],
          [1.09, 315.71, 2.94],
          [0.13, 416.93, 3.35],
          [19.88, 168.05, 5.95],
          [23.22, 168.19, 9.46],
          [112.9, 127.16, 9.96],
          [1341.46, 67.07, 14.81],
          [66.08, 109.66, 8.53],
          [0.09, 410.8, 2.87],
          [179.07, 69.48, 10.4],
          [43.99, 83.53, 10.08],
          [0.07, 629.83, 2.58],
          [1239.37, 68.84, 13.6],
          [3.86, 242.87, 5.04],
          [3.86, 196.87, 4.38],
          [2379.74, 49.58, 17.32],
          [20.52, 171.25, 9.01],
          [0.15, 419.8, 2.71],
          [364.75, 107.09, 18.14],
          [1.64, 307.71, 3.69],
          [191.36, 90.87, 12.92],
          [0.16, 456.05, 2.88],
          [12.56, 178.87, 6.61],
          [2593.34, 68.81, 21.23],
          [2.78, 198.95, 7.17],
          [0.09, 437.44, 3.64],
          [0.08, 463.07, 1.89],
          [0.16, 453.56, 2.15],
          [2917.84, 48.47, 13.08],
          [1686.19, 52.74, 18.43],
          [45.97, 172.18, 9.6],
          [4.57, 193.13, 4.62],
          [194.33, 95.38, 16.74]
        ]
      },
      "z": {
        "Diet": ["Other", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Other", "Herbivore", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other"]
      }
    },
    config = {
      "graphType": "Scatter2D",
      "titleAlign": "plot::0",
      "subtitleAlign": "plot::0",
      "legendHorizontalJustification": 0,
      "legendJustifyTo": "plot",
      "sizeScale": "area",
      "sizeMax": 40,
      "showSizeLegend": False,
      "theme": "classic",
      "xAxisGridMajorShow": True,
      "yAxisGridMajorShow": True,
      "title": "Large and herbivorous mammals have slow hearts",
      "subtitle": "Resting heart rate vs body mass in mammals (bubble size = lifespan)",
      "xAxis": ["Body mass (kg)"],
      "yAxis": ["Resting heart rate (bpm)"],
      "sizeBy": "Lifespan (years)",
      "colorBy": "Diet",
      "colorScheme": "User",
      "colors": ["rgba(26,152,103,0.7)", "rgba(150,150,150,0.55)"],
      "xAxisTransform": "log10",
      "xAxisTransformTicks": True,
      "setMinX": -3,
      "setMaxX": 4.3,
      "setMinY": 0,
      "setMaxY": 900,
      "showLegend": True,
      "legendPosition": "top",
      "legendColumns": 2,
      "xAxisTitle": "Body weight (kg), logarithmic scale",
      "yAxisTitle": "Resting heart rate (beats per minute)",
      "showDecorations": True,
      "decorations": {
        "marker": [
          {
            "type": "text",
            "variable": "Etruscan shrew",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Shrews",
            "offsetX": 14,
            "offsetY": 0,
            "align": "left"
          },
          {
            "type": "text",
            "variable": "House mouse",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Small rodents",
            "offsetX": 14,
            "offsetY": 0,
            "align": "left"
          },
          {
            "type": "text",
            "variable": "Human",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Humans",
            "offsetX": 22,
            "offsetY": -22,
            "align": "left",
            "fontStyle": "bold"
          },
          {
            "type": "text",
            "variable": "African elephant",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Elephants",
            "offsetX": 8,
            "offsetY": -30,
            "align": "center"
          },
          {
            "type": "text",
            "variable": "Horse",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Livestock",
            "offsetX": 0,
            "offsetY": 26,
            "align": "center"
          },
          {
            "type": "text",
            "variable": "Blue whale",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Whales",
            "offsetX": -24,
            "offsetY": -24,
            "align": "right"
          }
        ]
      }
    },
    width = 760,
    height = 600
  )

  # Display the chart in its own Web page
  show_in_browser(chart)
Run this notebook: Open in Binder
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph

graph(
  CanvasXpress(
    render_to = "scatter2d28",
    data = {
      "y": {
        "vars": ["Etruscan shrew", "House mouse", "Human", "Horse", "African elephant", "Blue whale", "Species 1", "Species 2", "Species 3", "Species 4", "Species 5", "Species 6", "Species 7", "Species 8", "Species 9", "Species 10", "Species 11", "Species 12", "Species 13", "Species 14", "Species 15", "Species 16", "Species 17", "Species 18", "Species 19", "Species 20", "Species 21", "Species 22", "Species 23", "Species 24", "Species 25", "Species 26", "Species 27", "Species 28", "Species 29", "Species 30", "Species 31", "Species 32", "Species 33", "Species 34", "Species 35", "Species 36", "Species 37", "Species 38", "Species 39", "Species 40", "Species 41", "Species 42", "Species 43", "Species 44", "Species 45", "Species 46"],
        "smps": ["Body mass (kg)", "Resting heart rate (bpm)", "Lifespan (years)"],
        "data": [
          [0.01, 720, 2],
          [0.025, 560, 3],
          [70, 70, 80],
          [500, 38, 28],
          [4500, 30, 65],
          [3000, 9, 80],
          [11.43, 154.84, 5.67],
          [0.08, 418.21, 2.85],
          [3.98, 203.11, 4.89],
          [3.02, 194.09, 3.98],
          [3.91, 218.31, 4.01],
          [0.57, 307.85, 4.53],
          [165.1, 85.51, 12.15],
          [560.45, 74.62, 19.29],
          [9.69, 174.72, 7.44],
          [52.54, 95.74, 8.49],
          [6.77, 225.3, 5.98],
          [1, 259.51, 5.69],
          [44.79, 142.11, 11.81],
          [581.52, 71.09, 11.28],
          [1.09, 315.71, 2.94],
          [0.13, 416.93, 3.35],
          [19.88, 168.05, 5.95],
          [23.22, 168.19, 9.46],
          [112.9, 127.16, 9.96],
          [1341.46, 67.07, 14.81],
          [66.08, 109.66, 8.53],
          [0.09, 410.8, 2.87],
          [179.07, 69.48, 10.4],
          [43.99, 83.53, 10.08],
          [0.07, 629.83, 2.58],
          [1239.37, 68.84, 13.6],
          [3.86, 242.87, 5.04],
          [3.86, 196.87, 4.38],
          [2379.74, 49.58, 17.32],
          [20.52, 171.25, 9.01],
          [0.15, 419.8, 2.71],
          [364.75, 107.09, 18.14],
          [1.64, 307.71, 3.69],
          [191.36, 90.87, 12.92],
          [0.16, 456.05, 2.88],
          [12.56, 178.87, 6.61],
          [2593.34, 68.81, 21.23],
          [2.78, 198.95, 7.17],
          [0.09, 437.44, 3.64],
          [0.08, 463.07, 1.89],
          [0.16, 453.56, 2.15],
          [2917.84, 48.47, 13.08],
          [1686.19, 52.74, 18.43],
          [45.97, 172.18, 9.6],
          [4.57, 193.13, 4.62],
          [194.33, 95.38, 16.74]
        ]
      },
      "z": {
        "Diet": ["Other", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Other", "Herbivore", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other"]
      }
    },
    config = {
      "graphType": "Scatter2D",
      "titleAlign": "plot::0",
      "subtitleAlign": "plot::0",
      "legendHorizontalJustification": 0,
      "legendJustifyTo": "plot",
      "sizeScale": "area",
      "sizeMax": 40,
      "showSizeLegend": False,
      "theme": "classic",
      "xAxisGridMajorShow": True,
      "yAxisGridMajorShow": True,
      "title": "Large and herbivorous mammals have slow hearts",
      "subtitle": "Resting heart rate vs body mass in mammals (bubble size = lifespan)",
      "xAxis": ["Body mass (kg)"],
      "yAxis": ["Resting heart rate (bpm)"],
      "sizeBy": "Lifespan (years)",
      "colorBy": "Diet",
      "colorScheme": "User",
      "colors": ["rgba(26,152,103,0.7)", "rgba(150,150,150,0.55)"],
      "xAxisTransform": "log10",
      "xAxisTransformTicks": True,
      "setMinX": -3,
      "setMaxX": 4.3,
      "setMinY": 0,
      "setMaxY": 900,
      "showLegend": True,
      "legendPosition": "top",
      "legendColumns": 2,
      "xAxisTitle": "Body weight (kg), logarithmic scale",
      "yAxisTitle": "Resting heart rate (beats per minute)",
      "showDecorations": True,
      "decorations": {
        "marker": [
          {
            "type": "text",
            "variable": "Etruscan shrew",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Shrews",
            "offsetX": 14,
            "offsetY": 0,
            "align": "left"
          },
          {
            "type": "text",
            "variable": "House mouse",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Small rodents",
            "offsetX": 14,
            "offsetY": 0,
            "align": "left"
          },
          {
            "type": "text",
            "variable": "Human",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Humans",
            "offsetX": 22,
            "offsetY": -22,
            "align": "left",
            "fontStyle": "bold"
          },
          {
            "type": "text",
            "variable": "African elephant",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Elephants",
            "offsetX": 8,
            "offsetY": -30,
            "align": "center"
          },
          {
            "type": "text",
            "variable": "Horse",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Livestock",
            "offsetX": 0,
            "offsetY": 26,
            "align": "center"
          },
          {
            "type": "text",
            "variable": "Blue whale",
            "sample": ["Body mass (kg)", "Resting heart rate (bpm)"],
            "text": "Whales",
            "offsetX": -24,
            "offsetY": -24,
            "align": "right"
          }
        ]
      }
    },
    width = 760,
    height = 600
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["Etruscan shrew", "House mouse", "Human", "Horse", "African elephant", "Blue whale", "Species 1", "Species 2", "Species 3", "Species 4", "Species 5", "Species 6", "Species 7", "Species 8", "Species 9", "Species 10", "Species 11", "Species 12", "Species 13", "Species 14", "Species 15", "Species 16", "Species 17", "Species 18", "Species 19", "Species 20", "Species 21", "Species 22", "Species 23", "Species 24", "Species 25", "Species 26", "Species 27", "Species 28", "Species 29", "Species 30", "Species 31", "Species 32", "Species 33", "Species 34", "Species 35", "Species 36", "Species 37", "Species 38", "Species 39", "Species 40", "Species 41", "Species 42", "Species 43", "Species 44", "Species 45", "Species 46"],
    "smps" => ["Body mass (kg)", "Resting heart rate (bpm)", "Lifespan (years)"],
    "data" => [
      [0.01, 720, 2],
      [0.025, 560, 3],
      [70, 70, 80],
      [500, 38, 28],
      [4500, 30, 65],
      [3000, 9, 80],
      [11.43, 154.84, 5.67],
      [0.08, 418.21, 2.85],
      [3.98, 203.11, 4.89],
      [3.02, 194.09, 3.98],
      [3.91, 218.31, 4.01],
      [0.57, 307.85, 4.53],
      [165.1, 85.51, 12.15],
      [560.45, 74.62, 19.29],
      [9.69, 174.72, 7.44],
      [52.54, 95.74, 8.49],
      [6.77, 225.3, 5.98],
      [1, 259.51, 5.69],
      [44.79, 142.11, 11.81],
      [581.52, 71.09, 11.28],
      [1.09, 315.71, 2.94],
      [0.13, 416.93, 3.35],
      [19.88, 168.05, 5.95],
      [23.22, 168.19, 9.46],
      [112.9, 127.16, 9.96],
      [1341.46, 67.07, 14.81],
      [66.08, 109.66, 8.53],
      [0.09, 410.8, 2.87],
      [179.07, 69.48, 10.4],
      [43.99, 83.53, 10.08],
      [0.07, 629.83, 2.58],
      [1239.37, 68.84, 13.6],
      [3.86, 242.87, 5.04],
      [3.86, 196.87, 4.38],
      [2379.74, 49.58, 17.32],
      [20.52, 171.25, 9.01],
      [0.15, 419.8, 2.71],
      [364.75, 107.09, 18.14],
      [1.64, 307.71, 3.69],
      [191.36, 90.87, 12.92],
      [0.16, 456.05, 2.88],
      [12.56, 178.87, 6.61],
      [2593.34, 68.81, 21.23],
      [2.78, 198.95, 7.17],
      [0.09, 437.44, 3.64],
      [0.08, 463.07, 1.89],
      [0.16, 453.56, 2.15],
      [2917.84, 48.47, 13.08],
      [1686.19, 52.74, 18.43],
      [45.97, 172.18, 9.6],
      [4.57, 193.13, 4.62],
      [194.33, 95.38, 16.74]
    ]
  ),
  "z" => Dict(
    "Diet" => ["Other", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Other", "Herbivore", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other", "Other", "Other", "Herbivore", "Herbivore", "Herbivore", "Other", "Herbivore", "Other", "Herbivore", "Herbivore", "Other", "Other", "Other"]
  )
);
  graphType = "Scatter2D",
  titleAlign = "plot::0",
  subtitleAlign = "plot::0",
  legendHorizontalJustification = 0,
  legendJustifyTo = "plot",
  sizeScale = "area",
  sizeMax = 40,
  showSizeLegend = false,
  theme = "classic",
  xAxisGridMajorShow = true,
  yAxisGridMajorShow = true,
  title = "Large and herbivorous mammals have slow hearts",
  subtitle = "Resting heart rate vs body mass in mammals (bubble size = lifespan)",
  xAxis = ["Body mass (kg)"],
  yAxis = ["Resting heart rate (bpm)"],
  sizeBy = "Lifespan (years)",
  colorBy = "Diet",
  colorScheme = "User",
  colors = ["rgba(26,152,103,0.7)", "rgba(150,150,150,0.55)"],
  xAxisTransform = "log10",
  xAxisTransformTicks = true,
  setMinX = -3,
  setMaxX = 4.3,
  setMinY = 0,
  setMaxY = 900,
  showLegend = true,
  legendPosition = "top",
  legendColumns = 2,
  xAxisTitle = "Body weight (kg), logarithmic scale",
  yAxisTitle = "Resting heart rate (beats per minute)",
  showDecorations = true,
  decorations = Dict(
    "marker" => [
      Dict(
        "type" => "text",
        "variable" => "Etruscan shrew",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Shrews",
        "offsetX" => 14,
        "offsetY" => 0,
        "align" => "left"
      ),
      Dict(
        "type" => "text",
        "variable" => "House mouse",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Small rodents",
        "offsetX" => 14,
        "offsetY" => 0,
        "align" => "left"
      ),
      Dict(
        "type" => "text",
        "variable" => "Human",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Humans",
        "offsetX" => 22,
        "offsetY" => -22,
        "align" => "left",
        "fontStyle" => "bold"
      ),
      Dict(
        "type" => "text",
        "variable" => "African elephant",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Elephants",
        "offsetX" => 8,
        "offsetY" => -30,
        "align" => "center"
      ),
      Dict(
        "type" => "text",
        "variable" => "Horse",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Livestock",
        "offsetX" => 0,
        "offsetY" => 26,
        "align" => "center"
      ),
      Dict(
        "type" => "text",
        "variable" => "Blue whale",
        "sample" => ["Body mass (kg)", "Resting heart rate (bpm)"],
        "text" => "Whales",
        "offsetX" => -24,
        "offsetY" => -24,
        "align" => "right"
      )
    ]
  )
)
⇧