Log y axis bubbles coloured by class
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 =
// Create the configuration for the graph
var config = {
"graphType" : "Scatter2D",
"titleAlign" : "plot::0",
"subtitleAlign" : "plot::0",
"legendHorizontalJustification" : 0,
"legendJustifyTo" : "plot",
"sizeScale" : "area",
"sizeMax" : 34,
"showSizeLegend" : false,
"theme" : "stata",
"legendBackgroundBorderColor" : "rgba(255,255,255,0)",
"xAxisGridMajorShow" : true,
"yAxisGridMajorShow" : true,
"xAxisGridMajorColor" : "rgb(200,212,214)",
"yAxisGridMajorColor" : "rgb(200,212,214)",
"title" : "Where are the small bodies of the Solar System?",
"subtitle" : "Distance from the Sun vs. temperature; size = diameter",
"xAxis" : [
"Mean surface temperature (K)"
],
"yAxis" : [
"Semi-major axis (AU)"
],
"sizeBy" : "Diameter (km)",
"colorBy" : "Class",
"colorScheme" : "User",
"colors" : [
"#76B7B2",
"#9C755F",
"#E15759",
"#4E79A7"
],
"xAxisTransform" : false,
"yAxisTransform" : "log10",
"yAxisTransformTicks" : true,
"setMinX" : 0,
"setMaxX" : 320,
"setMinY" : -0.3,
"setMaxY" : 2.9,
"showLegend" : true,
"legendPosition" : "top",
"xAxisTitle" : "Mean surface temperature (K)",
"yAxisTitle" : "Distance from the Sun (AU, log scale)",
"showDecorations" : true,
"decorations" : {
"range" : [
{
"y" : 0.3222192947339193,
"y2" : 0.5185139398778874,
"color" : "rgba(240,120,100,0.22)"
},
{
"y" : 1.4771212547196624,
"y2" : 1.6989700043360187,
"color" : "rgba(240,120,100,0.22)"
}
],
"marker" : [
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Ceres",
"offsetX" : -22,
"offsetY" : 0,
"align" : "right"
},
{
"type" : "text",
"variable" : "Vesta",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Vesta",
"offsetX" : 20,
"offsetY" : 0,
"align" : "left"
},
{
"type" : "text",
"variable" : "Hygiea",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Hygiea",
"offsetX" : 0,
"offsetY" : -16,
"align" : "center"
},
{
"type" : "text",
"variable" : "Eros",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Eros",
"offsetX" : 0,
"offsetY" : -14,
"align" : "center"
},
{
"type" : "text",
"variable" : "Apophis",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Apophis",
"offsetX" : 0,
"offsetY" : -14,
"align" : "center"
},
{
"type" : "text",
"variable" : "Chiron",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Chiron",
"offsetX" : 14,
"offsetY" : 12,
"align" : "left"
},
{
"type" : "text",
"variable" : "Chariklo",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Chariklo",
"offsetX" : 14,
"offsetY" : 2,
"align" : "left"
},
{
"type" : "text",
"variable" : "Pholus",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Pholus",
"offsetX" : 14,
"offsetY" : -8,
"align" : "left"
},
{
"type" : "text",
"variable" : "Eris",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Eris",
"offsetX" : 0,
"offsetY" : -34,
"align" : "center"
},
{
"type" : "text",
"variable" : "Pluto",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Pluto",
"offsetX" : -32,
"offsetY" : 0,
"align" : "right"
},
{
"type" : "text",
"variable" : "Makemake",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Makemake",
"offsetX" : 22,
"offsetY" : 14,
"align" : "left"
},
{
"type" : "text",
"variable" : "Sedna",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Sedna",
"offsetX" : 28,
"offsetY" : 0,
"align" : "left"
},
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Asteroid belt",
"x" : 0.88,
"y" : 0.72,
"fontSize" : 14,
"color" : "rgb(140,140,140)"
},
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Kuiper belt",
"x" : 0.88,
"y" : 0.36,
"fontSize" : 14,
"color" : "rgb(140,140,140)"
}
]
}
}
// 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" : [
"Ceres",
"Vesta",
"Hygiea",
"Eros",
"Apophis",
"Chiron",
"Chariklo",
"Pholus",
"Pluto",
"Makemake",
"Eris",
"Sedna"
],
"smps" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)",
"Diameter (km)"
],
"data" : [
[
168,
2.77,
470
],
[
177,
2.36,
260
],
[
150,
3.14,
215
],
[
227,
1.46,
8
],
[
262,
0.92,
0.2
],
[
80,
13.6,
100
],
[
70,
15.8,
120
],
[
60,
20.3,
90
],
[
44,
39.5,
1188
],
[
40,
45.5,
715
],
[
42,
67.8,
1163
],
[
12,
506,
500
]
]
},
"z" : {
"Class" : [
"Main-belt",
"Main-belt",
"Main-belt",
"Near-Earth",
"Near-Earth",
"Centaur",
"Centaur",
"Centaur",
"Trans-Neptunian",
"Trans-Neptunian",
"Trans-Neptunian",
"Trans-Neptunian"
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Scatter2D",
"titleAlign" : "plot::0",
"subtitleAlign" : "plot::0",
"legendHorizontalJustification" : 0,
"legendJustifyTo" : "plot",
"sizeScale" : "area",
"sizeMax" : 34,
"showSizeLegend" : false,
"theme" : "stata",
"legendBackgroundBorderColor" : "rgba(255,255,255,0)",
"xAxisGridMajorShow" : true,
"yAxisGridMajorShow" : true,
"xAxisGridMajorColor" : "rgb(200,212,214)",
"yAxisGridMajorColor" : "rgb(200,212,214)",
"title" : "Where are the small bodies of the Solar System?",
"subtitle" : "Distance from the Sun vs. temperature; size = diameter",
"xAxis" : [
"Mean surface temperature (K)"
],
"yAxis" : [
"Semi-major axis (AU)"
],
"sizeBy" : "Diameter (km)",
"colorBy" : "Class",
"colorScheme" : "User",
"colors" : [
"#76B7B2",
"#9C755F",
"#E15759",
"#4E79A7"
],
"xAxisTransform" : false,
"yAxisTransform" : "log10",
"yAxisTransformTicks" : true,
"setMinX" : 0,
"setMaxX" : 320,
"setMinY" : -0.3,
"setMaxY" : 2.9,
"showLegend" : true,
"legendPosition" : "top",
"xAxisTitle" : "Mean surface temperature (K)",
"yAxisTitle" : "Distance from the Sun (AU, log scale)",
"showDecorations" : true,
"decorations" : {
"range" : [
{
"y" : 0.3222192947339193,
"y2" : 0.5185139398778874,
"color" : "rgba(240,120,100,0.22)"
},
{
"y" : 1.4771212547196624,
"y2" : 1.6989700043360187,
"color" : "rgba(240,120,100,0.22)"
}
],
"marker" : [
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Ceres",
"offsetX" : -22,
"offsetY" : 0,
"align" : "right"
},
{
"type" : "text",
"variable" : "Vesta",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Vesta",
"offsetX" : 20,
"offsetY" : 0,
"align" : "left"
},
{
"type" : "text",
"variable" : "Hygiea",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Hygiea",
"offsetX" : 0,
"offsetY" : -16,
"align" : "center"
},
{
"type" : "text",
"variable" : "Eros",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Eros",
"offsetX" : 0,
"offsetY" : -14,
"align" : "center"
},
{
"type" : "text",
"variable" : "Apophis",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Apophis",
"offsetX" : 0,
"offsetY" : -14,
"align" : "center"
},
{
"type" : "text",
"variable" : "Chiron",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Chiron",
"offsetX" : 14,
"offsetY" : 12,
"align" : "left"
},
{
"type" : "text",
"variable" : "Chariklo",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Chariklo",
"offsetX" : 14,
"offsetY" : 2,
"align" : "left"
},
{
"type" : "text",
"variable" : "Pholus",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Pholus",
"offsetX" : 14,
"offsetY" : -8,
"align" : "left"
},
{
"type" : "text",
"variable" : "Eris",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Eris",
"offsetX" : 0,
"offsetY" : -34,
"align" : "center"
},
{
"type" : "text",
"variable" : "Pluto",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Pluto",
"offsetX" : -32,
"offsetY" : 0,
"align" : "right"
},
{
"type" : "text",
"variable" : "Makemake",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Makemake",
"offsetX" : 22,
"offsetY" : 14,
"align" : "left"
},
{
"type" : "text",
"variable" : "Sedna",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Sedna",
"offsetX" : 28,
"offsetY" : 0,
"align" : "left"
},
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Asteroid belt",
"x" : 0.88,
"y" : 0.72,
"fontSize" : 14,
"color" : "rgb(140,140,140)"
},
{
"type" : "text",
"variable" : "Ceres",
"sample" : [
"Mean surface temperature (K)",
"Semi-major axis (AU)"
],
"text" : "Kuiper belt",
"x" : 0.88,
"y" : 0.36,
"fontSize" : 14,
"color" : "rgb(140,140,140)"
}
]
}
}
// 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-scatter2d32-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-scatter2d32-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
varAnnot=z,
colorBy="Class",
colorScheme="User",
colors=list("#76B7B2", "#9C755F", "#E15759", "#4E79A7"),
decorations=list(marker=list(list(align="right", offsetX=-22, offsetY=0, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Ceres", type="text", variable="Ceres"), list(align="left", offsetX=20, offsetY=0, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Vesta", type="text", variable="Vesta"), list(align="center", offsetX=0, offsetY=-16, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Hygiea", type="text", variable="Hygiea"), list(align="center", offsetX=0, offsetY=-14, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Eros", type="text", variable="Eros"), list(align="center", offsetX=0, offsetY=-14, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Apophis", type="text", variable="Apophis"), list(align="left", offsetX=14, offsetY=12, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Chiron", type="text", variable="Chiron"), list(align="left", offsetX=14, offsetY=2, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Chariklo", type="text", variable="Chariklo"), list(align="left", offsetX=14, offsetY=-8, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Pholus", type="text", variable="Pholus"), list(align="center", offsetX=0, offsetY=-34, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Eris", type="text", variable="Eris"), list(align="right", offsetX=-32, offsetY=0, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Pluto", type="text", variable="Pluto"), list(align="left", offsetX=22, offsetY=14, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Makemake", type="text", variable="Makemake"), list(align="left", offsetX=28, offsetY=0, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Sedna", type="text", variable="Sedna"), list(color="rgb(140,140,140)", fontSize=14, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Asteroid belt", type="text", variable="Ceres", x=0.88, y=0.72), list(color="rgb(140,140,140)", fontSize=14, sample=list("Mean surface temperature (K)", "Semi-major axis (AU)"), text="Kuiper belt", type="text", variable="Ceres", x=0.88, y=0.36)), range=list(list(color="rgba(240,120,100,0.22)", y=0.3222192947339193, y2=0.5185139398778874), list(color="rgba(240,120,100,0.22)", y=1.4771212547196624, y2=1.6989700043360187))),
graphType="Scatter2D",
legendBackgroundBorderColor="rgba(255,255,255,0)",
legendHorizontalJustification=0,
legendJustifyTo="plot",
legendPosition="top",
setMaxX=320,
setMaxY=2.9,
setMinX=0,
setMinY=-0.3,
showDecorations=TRUE,
showLegend=TRUE,
showSizeLegend=FALSE,
sizeBy="Diameter (km)",
sizeMax=34,
sizeScale="area",
subtitle="Distance from the Sun vs. temperature; size = diameter",
subtitleAlign="plot::0",
theme="stata",
title="Where are the small bodies of the Solar System?",
titleAlign="plot::0",
xAxis=list("Mean surface temperature (K)"),
xAxisGridMajorColor="rgb(200,212,214)",
xAxisGridMajorShow=TRUE,
xAxisTitle="Mean surface temperature (K)",
xAxisTransform=FALSE,
yAxis=list("Semi-major axis (AU)"),
yAxisGridMajorColor="rgb(200,212,214)",
yAxisGridMajorShow=TRUE,
yAxisTitle="Distance from the Sun (AU, log scale)",
yAxisTransform="log10",
yAxisTransformTicks=TRUE
)
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 = "scatter2d32",
data = {
"y": {
"vars": ["Ceres", "Vesta", "Hygiea", "Eros", "Apophis", "Chiron", "Chariklo", "Pholus", "Pluto", "Makemake", "Eris", "Sedna"],
"smps": ["Mean surface temperature (K)", "Semi-major axis (AU)", "Diameter (km)"],
"data": [
[168, 2.77, 470],
[177, 2.36, 260],
[150, 3.14, 215],
[227, 1.46, 8],
[262, 0.92, 0.2],
[80, 13.6, 100],
[70, 15.8, 120],
[60, 20.3, 90],
[44, 39.5, 1188],
[40, 45.5, 715],
[42, 67.8, 1163],
[12, 506, 500]
]
},
"z": {
"Class": ["Main-belt", "Main-belt", "Main-belt", "Near-Earth", "Near-Earth", "Centaur", "Centaur", "Centaur", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian"]
}
},
config = {
"graphType": "Scatter2D",
"titleAlign": "plot::0",
"subtitleAlign": "plot::0",
"legendHorizontalJustification": 0,
"legendJustifyTo": "plot",
"sizeScale": "area",
"sizeMax": 34,
"showSizeLegend": False,
"theme": "stata",
"legendBackgroundBorderColor": "rgba(255,255,255,0)",
"xAxisGridMajorShow": True,
"yAxisGridMajorShow": True,
"xAxisGridMajorColor": "rgb(200,212,214)",
"yAxisGridMajorColor": "rgb(200,212,214)",
"title": "Where are the small bodies of the Solar System?",
"subtitle": "Distance from the Sun vs. temperature; size = diameter",
"xAxis": ["Mean surface temperature (K)"],
"yAxis": ["Semi-major axis (AU)"],
"sizeBy": "Diameter (km)",
"colorBy": "Class",
"colorScheme": "User",
"colors": ["#76B7B2", "#9C755F", "#E15759", "#4E79A7"],
"xAxisTransform": False,
"yAxisTransform": "log10",
"yAxisTransformTicks": True,
"setMinX": 0,
"setMaxX": 320,
"setMinY": -0.3,
"setMaxY": 2.9,
"showLegend": True,
"legendPosition": "top",
"xAxisTitle": "Mean surface temperature (K)",
"yAxisTitle": "Distance from the Sun (AU, log scale)",
"showDecorations": True,
"decorations": {
"range": [
{
"y": 0.3222192947339193,
"y2": 0.5185139398778874,
"color": "rgba(240,120,100,0.22)"
},
{
"y": 1.4771212547196624,
"y2": 1.6989700043360187,
"color": "rgba(240,120,100,0.22)"
}
],
"marker": [
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Ceres",
"offsetX": -22,
"offsetY": 0,
"align": "right"
},
{
"type": "text",
"variable": "Vesta",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Vesta",
"offsetX": 20,
"offsetY": 0,
"align": "left"
},
{
"type": "text",
"variable": "Hygiea",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Hygiea",
"offsetX": 0,
"offsetY": -16,
"align": "center"
},
{
"type": "text",
"variable": "Eros",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Eros",
"offsetX": 0,
"offsetY": -14,
"align": "center"
},
{
"type": "text",
"variable": "Apophis",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Apophis",
"offsetX": 0,
"offsetY": -14,
"align": "center"
},
{
"type": "text",
"variable": "Chiron",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Chiron",
"offsetX": 14,
"offsetY": 12,
"align": "left"
},
{
"type": "text",
"variable": "Chariklo",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Chariklo",
"offsetX": 14,
"offsetY": 2,
"align": "left"
},
{
"type": "text",
"variable": "Pholus",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Pholus",
"offsetX": 14,
"offsetY": -8,
"align": "left"
},
{
"type": "text",
"variable": "Eris",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Eris",
"offsetX": 0,
"offsetY": -34,
"align": "center"
},
{
"type": "text",
"variable": "Pluto",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Pluto",
"offsetX": -32,
"offsetY": 0,
"align": "right"
},
{
"type": "text",
"variable": "Makemake",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Makemake",
"offsetX": 22,
"offsetY": 14,
"align": "left"
},
{
"type": "text",
"variable": "Sedna",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Sedna",
"offsetX": 28,
"offsetY": 0,
"align": "left"
},
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Asteroid belt",
"x": 0.88,
"y": 0.72,
"fontSize": 14,
"color": "rgb(140,140,140)"
},
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Kuiper belt",
"x": 0.88,
"y": 0.36,
"fontSize": 14,
"color": "rgb(140,140,140)"
}
]
}
},
width = 760,
height = 640
)
# Display the chart in its own Web page
show_in_browser(chart)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph
graph(
CanvasXpress(
render_to = "scatter2d32",
data = {
"y": {
"vars": ["Ceres", "Vesta", "Hygiea", "Eros", "Apophis", "Chiron", "Chariklo", "Pholus", "Pluto", "Makemake", "Eris", "Sedna"],
"smps": ["Mean surface temperature (K)", "Semi-major axis (AU)", "Diameter (km)"],
"data": [
[168, 2.77, 470],
[177, 2.36, 260],
[150, 3.14, 215],
[227, 1.46, 8],
[262, 0.92, 0.2],
[80, 13.6, 100],
[70, 15.8, 120],
[60, 20.3, 90],
[44, 39.5, 1188],
[40, 45.5, 715],
[42, 67.8, 1163],
[12, 506, 500]
]
},
"z": {
"Class": ["Main-belt", "Main-belt", "Main-belt", "Near-Earth", "Near-Earth", "Centaur", "Centaur", "Centaur", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian"]
}
},
config = {
"graphType": "Scatter2D",
"titleAlign": "plot::0",
"subtitleAlign": "plot::0",
"legendHorizontalJustification": 0,
"legendJustifyTo": "plot",
"sizeScale": "area",
"sizeMax": 34,
"showSizeLegend": False,
"theme": "stata",
"legendBackgroundBorderColor": "rgba(255,255,255,0)",
"xAxisGridMajorShow": True,
"yAxisGridMajorShow": True,
"xAxisGridMajorColor": "rgb(200,212,214)",
"yAxisGridMajorColor": "rgb(200,212,214)",
"title": "Where are the small bodies of the Solar System?",
"subtitle": "Distance from the Sun vs. temperature; size = diameter",
"xAxis": ["Mean surface temperature (K)"],
"yAxis": ["Semi-major axis (AU)"],
"sizeBy": "Diameter (km)",
"colorBy": "Class",
"colorScheme": "User",
"colors": ["#76B7B2", "#9C755F", "#E15759", "#4E79A7"],
"xAxisTransform": False,
"yAxisTransform": "log10",
"yAxisTransformTicks": True,
"setMinX": 0,
"setMaxX": 320,
"setMinY": -0.3,
"setMaxY": 2.9,
"showLegend": True,
"legendPosition": "top",
"xAxisTitle": "Mean surface temperature (K)",
"yAxisTitle": "Distance from the Sun (AU, log scale)",
"showDecorations": True,
"decorations": {
"range": [
{
"y": 0.3222192947339193,
"y2": 0.5185139398778874,
"color": "rgba(240,120,100,0.22)"
},
{
"y": 1.4771212547196624,
"y2": 1.6989700043360187,
"color": "rgba(240,120,100,0.22)"
}
],
"marker": [
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Ceres",
"offsetX": -22,
"offsetY": 0,
"align": "right"
},
{
"type": "text",
"variable": "Vesta",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Vesta",
"offsetX": 20,
"offsetY": 0,
"align": "left"
},
{
"type": "text",
"variable": "Hygiea",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Hygiea",
"offsetX": 0,
"offsetY": -16,
"align": "center"
},
{
"type": "text",
"variable": "Eros",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Eros",
"offsetX": 0,
"offsetY": -14,
"align": "center"
},
{
"type": "text",
"variable": "Apophis",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Apophis",
"offsetX": 0,
"offsetY": -14,
"align": "center"
},
{
"type": "text",
"variable": "Chiron",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Chiron",
"offsetX": 14,
"offsetY": 12,
"align": "left"
},
{
"type": "text",
"variable": "Chariklo",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Chariklo",
"offsetX": 14,
"offsetY": 2,
"align": "left"
},
{
"type": "text",
"variable": "Pholus",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Pholus",
"offsetX": 14,
"offsetY": -8,
"align": "left"
},
{
"type": "text",
"variable": "Eris",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Eris",
"offsetX": 0,
"offsetY": -34,
"align": "center"
},
{
"type": "text",
"variable": "Pluto",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Pluto",
"offsetX": -32,
"offsetY": 0,
"align": "right"
},
{
"type": "text",
"variable": "Makemake",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Makemake",
"offsetX": 22,
"offsetY": 14,
"align": "left"
},
{
"type": "text",
"variable": "Sedna",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Sedna",
"offsetX": 28,
"offsetY": 0,
"align": "left"
},
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Asteroid belt",
"x": 0.88,
"y": 0.72,
"fontSize": 14,
"color": "rgb(140,140,140)"
},
{
"type": "text",
"variable": "Ceres",
"sample": ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text": "Kuiper belt",
"x": 0.88,
"y": 0.36,
"fontSize": 14,
"color": "rgb(140,140,140)"
}
]
}
},
width = 760,
height = 640
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Ceres", "Vesta", "Hygiea", "Eros", "Apophis", "Chiron", "Chariklo", "Pholus", "Pluto", "Makemake", "Eris", "Sedna"],
"smps" => ["Mean surface temperature (K)", "Semi-major axis (AU)", "Diameter (km)"],
"data" => [
[168, 2.77, 470],
[177, 2.36, 260],
[150, 3.14, 215],
[227, 1.46, 8],
[262, 0.92, 0.2],
[80, 13.6, 100],
[70, 15.8, 120],
[60, 20.3, 90],
[44, 39.5, 1188],
[40, 45.5, 715],
[42, 67.8, 1163],
[12, 506, 500]
]
),
"z" => Dict(
"Class" => ["Main-belt", "Main-belt", "Main-belt", "Near-Earth", "Near-Earth", "Centaur", "Centaur", "Centaur", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian", "Trans-Neptunian"]
)
);
graphType = "Scatter2D",
titleAlign = "plot::0",
subtitleAlign = "plot::0",
legendHorizontalJustification = 0,
legendJustifyTo = "plot",
sizeScale = "area",
sizeMax = 34,
showSizeLegend = false,
theme = "stata",
legendBackgroundBorderColor = "rgba(255,255,255,0)",
xAxisGridMajorShow = true,
yAxisGridMajorShow = true,
xAxisGridMajorColor = "rgb(200,212,214)",
yAxisGridMajorColor = "rgb(200,212,214)",
title = "Where are the small bodies of the Solar System?",
subtitle = "Distance from the Sun vs. temperature; size = diameter",
xAxis = ["Mean surface temperature (K)"],
yAxis = ["Semi-major axis (AU)"],
sizeBy = "Diameter (km)",
colorBy = "Class",
colorScheme = "User",
colors = ["#76B7B2", "#9C755F", "#E15759", "#4E79A7"],
xAxisTransform = false,
yAxisTransform = "log10",
yAxisTransformTicks = true,
setMinX = 0,
setMaxX = 320,
setMinY = -0.3,
setMaxY = 2.9,
showLegend = true,
legendPosition = "top",
xAxisTitle = "Mean surface temperature (K)",
yAxisTitle = "Distance from the Sun (AU, log scale)",
showDecorations = true,
decorations = Dict(
"range" => [
Dict(
"y" => 0.3222192947339193,
"y2" => 0.5185139398778874,
"color" => "rgba(240,120,100,0.22)"
),
Dict(
"y" => 1.4771212547196624,
"y2" => 1.6989700043360187,
"color" => "rgba(240,120,100,0.22)"
)
],
"marker" => [
Dict(
"type" => "text",
"variable" => "Ceres",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Ceres",
"offsetX" => -22,
"offsetY" => 0,
"align" => "right"
),
Dict(
"type" => "text",
"variable" => "Vesta",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Vesta",
"offsetX" => 20,
"offsetY" => 0,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Hygiea",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Hygiea",
"offsetX" => 0,
"offsetY" => -16,
"align" => "center"
),
Dict(
"type" => "text",
"variable" => "Eros",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Eros",
"offsetX" => 0,
"offsetY" => -14,
"align" => "center"
),
Dict(
"type" => "text",
"variable" => "Apophis",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Apophis",
"offsetX" => 0,
"offsetY" => -14,
"align" => "center"
),
Dict(
"type" => "text",
"variable" => "Chiron",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Chiron",
"offsetX" => 14,
"offsetY" => 12,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Chariklo",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Chariklo",
"offsetX" => 14,
"offsetY" => 2,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Pholus",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Pholus",
"offsetX" => 14,
"offsetY" => -8,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Eris",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Eris",
"offsetX" => 0,
"offsetY" => -34,
"align" => "center"
),
Dict(
"type" => "text",
"variable" => "Pluto",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Pluto",
"offsetX" => -32,
"offsetY" => 0,
"align" => "right"
),
Dict(
"type" => "text",
"variable" => "Makemake",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Makemake",
"offsetX" => 22,
"offsetY" => 14,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Sedna",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Sedna",
"offsetX" => 28,
"offsetY" => 0,
"align" => "left"
),
Dict(
"type" => "text",
"variable" => "Ceres",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Asteroid belt",
"x" => 0.88,
"y" => 0.72,
"fontSize" => 14,
"color" => "rgb(140,140,140)"
),
Dict(
"type" => "text",
"variable" => "Ceres",
"sample" => ["Mean surface temperature (K)", "Semi-major axis (AU)"],
"text" => "Kuiper belt",
"x" => 0.88,
"y" => 0.36,
"fontSize" => 14,
"color" => "rgb(140,140,140)"
)
]
)
)

































