Long sorted min-max list with coloured ends
Dumbbell graphs display the relationship between two data points for multiple categories by connecting them with a line. It effectively shows the difference or change between these two values for each item, allowing for easy comparison of magnitudes and variations across the dataset. This visualization is useful for highlighting shifts or disparities.
<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" : "Dumbbell",
"dumbbellType" : "connected",
"theme" : "ggplot",
"colorScheme" : "User",
"colors" : [
"#0072B2",
"#009E73"
],
"title" : "How hot are the reefs?",
"subtitle" : "Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
"xAxis" : [
"Winter minimum",
"Summer maximum"
],
"xAxisTitle" : "Temperature (°C)",
"sortDir" : "ascending",
"sortBy" : "Summer maximum",
"smpLabelInterval" : 1,
"smpTextScaleFontFactor" : 0.7,
"legendPosition" : "top",
"dataPointSizeScaleFactor" : 1,
"citation" : "Source: synthetic data for illustration"
}
// 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" : [
"Winter minimum",
"Summer maximum"
],
"smps" : [
"Moorea",
"Bora Bora",
"Rangiroa",
"Tahiti",
"Heron Is.",
"Lizard Is.",
"Ningaloo",
"Raja Ampat",
"Komodo",
"Bunaken",
"Palau",
"Chuuk",
"Yap",
"Guam",
"Okinawa",
"Ishigaki",
"Hainan",
"Spratly",
"Cebu",
"Apo Reef",
"Maldives N",
"Maldives S",
"Chagos",
"Seychelles",
"Zanzibar",
"Mafia Is.",
"Red Sea N",
"Red Sea S",
"Eilat",
"Bonaire",
"Curacao",
"Belize",
"Florida Keys",
"Bahamas",
"Cayman",
"Jamaica",
"Puerto Rico",
"St Croix",
"Barbados",
"Tobago"
],
"data" : [
[
23.2,
23.8,
25.6,
22.4,
22.5,
25.9,
23.8,
24.6,
24,
25.3,
22.6,
25.9,
23.5,
24.9,
23.8,
26,
26.8,
23.8,
22.2,
26.3,
23.4,
25.8,
25.6,
24.3,
24.9,
23.3,
24.3,
25.8,
22.2,
24,
23.4,
22.7,
22.2,
23.4,
25.7,
23,
23,
23.9,
22.3,
26.9
],
[
27.1,
26.3,
33.5,
29.4,
26,
29.8,
28.3,
31.1,
29.3,
30.1,
29.8,
28.1,
26.4,
27.2,
32.3,
33.1,
29.2,
31.2,
25.7,
29.5,
31.5,
34.3,
28.7,
30.5,
29.7,
29.6,
26.6,
28.8,
29,
30.1,
32.4,
25.9,
27.8,
27.7,
31.2,
28.8,
29.3,
27,
29.2,
29.1
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Dumbbell",
"dumbbellType" : "connected",
"theme" : "ggplot",
"colorScheme" : "User",
"colors" : [
"#0072B2",
"#009E73"
],
"title" : "How hot are the reefs?",
"subtitle" : "Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
"xAxis" : [
"Winter minimum",
"Summer maximum"
],
"xAxisTitle" : "Temperature (°C)",
"sortDir" : "ascending",
"sortBy" : "Summer maximum",
"smpLabelInterval" : 1,
"smpTextScaleFontFactor" : 0.7,
"legendPosition" : "top",
"dataPointSizeScaleFactor" : 1,
"citation" : "Source: synthetic data for illustration"
}
// 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-dumbbell14-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
citation="Source: synthetic data for illustration",
colorScheme="User",
colors=list("#0072B2", "#009E73"),
dataPointSizeScaleFactor=1,
dumbbellType="connected",
graphType="Dumbbell",
legendPosition="top",
smpLabelInterval=1,
smpTextScaleFontFactor=0.7,
sortBy="Summer maximum",
sortDir="ascending",
subtitle="Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
theme="ggplot",
title="How hot are the reefs?",
xAxis=list("Winter minimum", "Summer maximum"),
xAxisTitle="Temperature (°C)"
)
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 = "dumbbell14",
data = {
"y": {
"vars": ["Winter minimum", "Summer maximum"],
"smps": ["Moorea", "Bora Bora", "Rangiroa", "Tahiti", "Heron Is.", "Lizard Is.", "Ningaloo", "Raja Ampat", "Komodo", "Bunaken", "Palau", "Chuuk", "Yap", "Guam", "Okinawa", "Ishigaki", "Hainan", "Spratly", "Cebu", "Apo Reef", "Maldives N", "Maldives S", "Chagos", "Seychelles", "Zanzibar", "Mafia Is.", "Red Sea N", "Red Sea S", "Eilat", "Bonaire", "Curacao", "Belize", "Florida Keys", "Bahamas", "Cayman", "Jamaica", "Puerto Rico", "St Croix", "Barbados", "Tobago"],
"data": [
[23.2, 23.8, 25.6, 22.4, 22.5, 25.9, 23.8, 24.6, 24, 25.3, 22.6, 25.9, 23.5, 24.9, 23.8, 26, 26.8, 23.8, 22.2, 26.3, 23.4, 25.8, 25.6, 24.3, 24.9, 23.3, 24.3, 25.8, 22.2, 24, 23.4, 22.7, 22.2, 23.4, 25.7, 23, 23, 23.9, 22.3, 26.9],
[27.1, 26.3, 33.5, 29.4, 26, 29.8, 28.3, 31.1, 29.3, 30.1, 29.8, 28.1, 26.4, 27.2, 32.3, 33.1, 29.2, 31.2, 25.7, 29.5, 31.5, 34.3, 28.7, 30.5, 29.7, 29.6, 26.6, 28.8, 29, 30.1, 32.4, 25.9, 27.8, 27.7, 31.2, 28.8, 29.3, 27, 29.2, 29.1]
]
}
},
config = {
"graphType": "Dumbbell",
"dumbbellType": "connected",
"theme": "ggplot",
"colorScheme": "User",
"colors": ["#0072B2", "#009E73"],
"title": "How hot are the reefs?",
"subtitle": "Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
"xAxis": ["Winter minimum", "Summer maximum"],
"xAxisTitle": "Temperature (°C)",
"sortDir": "ascending",
"sortBy": "Summer maximum",
"smpLabelInterval": 1,
"smpTextScaleFontFactor": 0.7,
"legendPosition": "top",
"dataPointSizeScaleFactor": 1,
"citation": "Source: synthetic data for illustration"
},
width = 760,
height = 900
)
# 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 = "dumbbell14",
data = {
"y": {
"vars": ["Winter minimum", "Summer maximum"],
"smps": ["Moorea", "Bora Bora", "Rangiroa", "Tahiti", "Heron Is.", "Lizard Is.", "Ningaloo", "Raja Ampat", "Komodo", "Bunaken", "Palau", "Chuuk", "Yap", "Guam", "Okinawa", "Ishigaki", "Hainan", "Spratly", "Cebu", "Apo Reef", "Maldives N", "Maldives S", "Chagos", "Seychelles", "Zanzibar", "Mafia Is.", "Red Sea N", "Red Sea S", "Eilat", "Bonaire", "Curacao", "Belize", "Florida Keys", "Bahamas", "Cayman", "Jamaica", "Puerto Rico", "St Croix", "Barbados", "Tobago"],
"data": [
[23.2, 23.8, 25.6, 22.4, 22.5, 25.9, 23.8, 24.6, 24, 25.3, 22.6, 25.9, 23.5, 24.9, 23.8, 26, 26.8, 23.8, 22.2, 26.3, 23.4, 25.8, 25.6, 24.3, 24.9, 23.3, 24.3, 25.8, 22.2, 24, 23.4, 22.7, 22.2, 23.4, 25.7, 23, 23, 23.9, 22.3, 26.9],
[27.1, 26.3, 33.5, 29.4, 26, 29.8, 28.3, 31.1, 29.3, 30.1, 29.8, 28.1, 26.4, 27.2, 32.3, 33.1, 29.2, 31.2, 25.7, 29.5, 31.5, 34.3, 28.7, 30.5, 29.7, 29.6, 26.6, 28.8, 29, 30.1, 32.4, 25.9, 27.8, 27.7, 31.2, 28.8, 29.3, 27, 29.2, 29.1]
]
}
},
config = {
"graphType": "Dumbbell",
"dumbbellType": "connected",
"theme": "ggplot",
"colorScheme": "User",
"colors": ["#0072B2", "#009E73"],
"title": "How hot are the reefs?",
"subtitle": "Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
"xAxis": ["Winter minimum", "Summer maximum"],
"xAxisTitle": "Temperature (°C)",
"sortDir": "ascending",
"sortBy": "Summer maximum",
"smpLabelInterval": 1,
"smpTextScaleFontFactor": 0.7,
"legendPosition": "top",
"dataPointSizeScaleFactor": 1,
"citation": "Source: synthetic data for illustration"
},
width = 760,
height = 900
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Winter minimum", "Summer maximum"],
"smps" => ["Moorea", "Bora Bora", "Rangiroa", "Tahiti", "Heron Is.", "Lizard Is.", "Ningaloo", "Raja Ampat", "Komodo", "Bunaken", "Palau", "Chuuk", "Yap", "Guam", "Okinawa", "Ishigaki", "Hainan", "Spratly", "Cebu", "Apo Reef", "Maldives N", "Maldives S", "Chagos", "Seychelles", "Zanzibar", "Mafia Is.", "Red Sea N", "Red Sea S", "Eilat", "Bonaire", "Curacao", "Belize", "Florida Keys", "Bahamas", "Cayman", "Jamaica", "Puerto Rico", "St Croix", "Barbados", "Tobago"],
"data" => [
[23.2, 23.8, 25.6, 22.4, 22.5, 25.9, 23.8, 24.6, 24, 25.3, 22.6, 25.9, 23.5, 24.9, 23.8, 26, 26.8, 23.8, 22.2, 26.3, 23.4, 25.8, 25.6, 24.3, 24.9, 23.3, 24.3, 25.8, 22.2, 24, 23.4, 22.7, 22.2, 23.4, 25.7, 23, 23, 23.9, 22.3, 26.9],
[27.1, 26.3, 33.5, 29.4, 26, 29.8, 28.3, 31.1, 29.3, 30.1, 29.8, 28.1, 26.4, 27.2, 32.3, 33.1, 29.2, 31.2, 25.7, 29.5, 31.5, 34.3, 28.7, 30.5, 29.7, 29.6, 26.6, 28.8, 29, 30.1, 32.4, 25.9, 27.8, 27.7, 31.2, 28.8, 29.3, 27, 29.2, 29.1]
]
)
);
graphType = "Dumbbell",
dumbbellType = "connected",
theme = "ggplot",
colorScheme = "User",
colors = ["#0072B2", "#009E73"],
title = "How hot are the reefs?",
subtitle = "Annual minimum and maximum sea-surface temperature at 40 monitoring sites (°C)",
xAxis = ["Winter minimum", "Summer maximum"],
xAxisTitle = "Temperature (°C)",
sortDir = "ascending",
sortBy = "Summer maximum",
smpLabelInterval = 1,
smpTextScaleFontFactor = 0.7,
legendPosition = "top",
dataPointSizeScaleFactor = 1,
citation = "Source: synthetic data for illustration"
)
















