World choropleth with a heavy-tailed scale
Maps in CanvasXpress allow users to create interactive and customizable visualizations for geographical data. You can integrate various map types, such as choropleths or point maps, and layer your data to highlight trends, distributions, or relationships across regions. With its flexibility, Maps in CanvasXpress support detailed analysis and presentation of spatial data for a wide range of applications.
<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" : "Map",
"topoJSON" : "https://www.canvasxpress.org/data/maps/WORLD.json",
"mapId" : "worldCo2",
"theme" : "stata",
"colorBy" : "Cumulative CO2 (Gt)",
"colorSpectrum" : [
"#2166ac",
"#92c5de",
"#f7f7f7",
"#f4a582",
"#b2182b"
],
"colorSpectrumBreaksMethod" : "quantile",
"title" : "Who has emitted the most CO2?",
"subtitle" : "Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
"legendPosition" : "bottomLeft",
"legendInside" : true,
"showLegendTitle" : true,
"mapColor" : "#e0e0e0",
"decorations" : {
"marker" : [
{
"coords" : [
37,
-98
],
"shape" : "none",
"type" : "curved",
"fontSize" : 12,
"text" : "The U.S. has emitted\n1.75x as much CO2\nas China since 1750",
"x" : 0.13,
"y" : 0.66
}
]
}
}
// 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" : [
"AFG",
"AGO",
"ALB",
"ARE",
"ARG",
"ARM",
"AUS",
"AUT",
"AZE",
"BDI",
"BEL",
"BEN",
"BFA",
"BGD",
"BGR",
"BIH",
"BLR",
"BOL",
"BRA",
"BWA",
"CAF",
"CAN",
"CHE",
"CHL",
"CHN",
"CIV",
"CMR",
"COD",
"COG",
"COL",
"CRI",
"CUB",
"CZE",
"DEU",
"DNK",
"DOM",
"DZA",
"ECU",
"EGY",
"ESP",
"EST",
"ETH",
"FIN",
"FRA",
"GAB",
"GBR",
"GEO",
"GHA",
"GIN",
"GRC",
"GTM",
"HND",
"HRV",
"HTI",
"HUN",
"IDN",
"IND",
"IRL",
"IRN",
"IRQ",
"ISL",
"ISR",
"ITA",
"JAM",
"JOR",
"JPN",
"KAZ",
"KEN",
"KGZ",
"KHM",
"KOR",
"KWT",
"LAO",
"LBN",
"LBR",
"LBY",
"LKA",
"LSO",
"LTU",
"LVA",
"MAR",
"MDG",
"MEX",
"MLI",
"MMR",
"MNG",
"MOZ",
"MRT",
"MWI",
"MYS",
"NAM",
"NER",
"NGA",
"NIC",
"NLD",
"NOR",
"NPL",
"NZL",
"OMN",
"PAK",
"PAN",
"PER",
"PHL",
"PNG",
"POL",
"PRK",
"PRT",
"PRY",
"QAT",
"ROU",
"RUS",
"RWA",
"SAU",
"SDN",
"SEN",
"SLE",
"SLV",
"SOM",
"SRB",
"SVK",
"SVN",
"SWE",
"SYR",
"TCD",
"TGO",
"THA",
"TJK",
"TKM",
"TUN",
"TUR",
"TZA",
"UGA",
"UKR",
"URY",
"USA",
"UZB",
"VEN",
"VNM",
"YEM",
"ZAF",
"ZMB",
"ZWE"
],
"smps" : [
"Cumulative CO2 (Gt)"
],
"data" : [
[
19.2
],
[
196.7
],
[
1.8
],
[
56.6
],
[
4.1
],
[
27.2
],
[
3.7
],
[
163.2
],
[
34.8
],
[
17.5
],
[
28.8
],
[
74
],
[
4.7
],
[
58.1
],
[
139.6
],
[
113.1
],
[
165.5
],
[
4.8
],
[
28.9
],
[
60
],
[
2.7
],
[
15.7
],
[
3.4
],
[
38.5
],
[
235
],
[
60.7
],
[
7.2
],
[
39.6
],
[
15.7
],
[
26.1
],
[
173.1
],
[
9
],
[
9
],
[
92
],
[
3
],
[
127.5
],
[
131.7
],
[
2.9
],
[
4.6
],
[
25.1
],
[
46
],
[
7.3
],
[
98.9
],
[
3.7
],
[
4.6
],
[
78
],
[
1.8
],
[
24.6
],
[
190.8
],
[
125.5
],
[
2
],
[
6.7
],
[
7
],
[
117.7
],
[
18.6
],
[
11.6
],
[
60
],
[
57.9
],
[
17.1
],
[
7.1
],
[
14.5
],
[
186.3
],
[
31.4
],
[
5.5
],
[
2.8
],
[
65
],
[
55.4
],
[
16.1
],
[
8.1
],
[
88.9
],
[
75.1
],
[
128.4
],
[
14.6
],
[
17.1
],
[
2.8
],
[
6.9
],
[
7.7
],
[
97
],
[
9
],
[
5.9
],
[
10.2
],
[
1.7
],
[
138.8
],
[
49.9
],
[
1.7
],
[
1.9
],
[
5.8
],
[
10
],
[
4.3
],
[
12.6
],
[
2.9
],
[
14.1
],
[
174.5
],
[
76
],
[
11.5
],
[
150.4
],
[
5.5
],
[
3.2
],
[
3.1
],
[
6.4
],
[
20.7
],
[
86
],
[
2.4
],
[
6.9
],
[
57.7
],
[
40.8
],
[
21.6
],
[
11.9
],
[
10.1
],
[
56.6
],
[
120
],
[
35.1
],
[
14.8
],
[
4.5
],
[
6.7
],
[
109.4
],
[
1.7
],
[
7.3
],
[
2.3
],
[
2.8
],
[
4.4
],
[
20.8
],
[
14.6
],
[
1.7
],
[
5.2
],
[
6.8
],
[
8.3
],
[
39
],
[
2.3
],
[
6.1
],
[
53.5
],
[
6.9
],
[
2.6
],
[
13
],
[
410
],
[
51.4
],
[
1.8
],
[
19.4
],
[
82.4
],
[
168.2
],
[
6.8
],
[
15.9
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Map",
"topoJSON" : "https://www.canvasxpress.org/data/maps/WORLD.json",
"mapId" : "worldCo2",
"theme" : "stata",
"colorBy" : "Cumulative CO2 (Gt)",
"colorSpectrum" : [
"#2166ac",
"#92c5de",
"#f7f7f7",
"#f4a582",
"#b2182b"
],
"colorSpectrumBreaksMethod" : "quantile",
"title" : "Who has emitted the most CO2?",
"subtitle" : "Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
"legendPosition" : "bottomLeft",
"legendInside" : true,
"showLegendTitle" : true,
"mapColor" : "#e0e0e0",
"decorations" : {
"marker" : [
{
"coords" : [
37,
-98
],
"shape" : "none",
"type" : "curved",
"fontSize" : 12,
"text" : "The U.S. has emitted\n1.75x as much CO2\nas China since 1750",
"x" : 0.13,
"y" : 0.66
}
]
}
}
// 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-map23-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
colorBy="Cumulative CO2 (Gt)",
colorSpectrum=list("#2166ac", "#92c5de", "#f7f7f7", "#f4a582", "#b2182b"),
colorSpectrumBreaksMethod="quantile",
decorations=list(marker=list(list(coords=list(37, -98), fontSize=12, shape="none", text="The U.S. has emitted\n1.75x as much CO2\nas China since 1750", type="curved", x=0.13, y=0.66))),
graphType="Map",
legendInside=TRUE,
legendPosition="bottomLeft",
mapColor="#e0e0e0",
mapId="worldCo2",
showLegendTitle=TRUE,
subtitle="Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
theme="stata",
title="Who has emitted the most CO2?",
topoJSON="https://www.canvasxpress.org/data/maps/WORLD.json"
)
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 = "map22",
data = {
"y": {
"vars": ["AFG", "AGO", "ALB", "ARE", "ARG", "ARM", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BFA", "BGD", "BGR", "BIH", "BLR", "BOL", "BRA", "BWA", "CAF", "CAN", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COL", "CRI", "CUB", "CZE", "DEU", "DNK", "DOM", "DZA", "ECU", "EGY", "ESP", "EST", "ETH", "FIN", "FRA", "GAB", "GBR", "GEO", "GHA", "GIN", "GRC", "GTM", "HND", "HRV", "HTI", "HUN", "IDN", "IND", "IRL", "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JOR", "JPN", "KAZ", "KEN", "KGZ", "KHM", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LKA", "LSO", "LTU", "LVA", "MAR", "MDG", "MEX", "MLI", "MMR", "MNG", "MOZ", "MRT", "MWI", "MYS", "NAM", "NER", "NGA", "NIC", "NLD", "NOR", "NPL", "NZL", "OMN", "PAK", "PAN", "PER", "PHL", "PNG", "POL", "PRK", "PRT", "PRY", "QAT", "ROU", "RUS", "RWA", "SAU", "SDN", "SEN", "SLE", "SLV", "SOM", "SRB", "SVK", "SVN", "SWE", "SYR", "TCD", "TGO", "THA", "TJK", "TKM", "TUN", "TUR", "TZA", "UGA", "UKR", "URY", "USA", "UZB", "VEN", "VNM", "YEM", "ZAF", "ZMB", "ZWE"],
"smps": ["Cumulative CO2 (Gt)"],
"data": [
[19.2],
[196.7],
[1.8],
[56.6],
[4.1],
[27.2],
[3.7],
[163.2],
[34.8],
[17.5],
[28.8],
[74],
[4.7],
[58.1],
[139.6],
[113.1],
[165.5],
[4.8],
[28.9],
[60],
[2.7],
[15.7],
[3.4],
[38.5],
[235],
[60.7],
[7.2],
[39.6],
[15.7],
[26.1],
[173.1],
[9],
[9],
[92],
[3],
[127.5],
[131.7],
[2.9],
[4.6],
[25.1],
[46],
[7.3],
[98.9],
[3.7],
[4.6],
[78],
[1.8],
[24.6],
[190.8],
[125.5],
[2],
[6.7],
[7],
[117.7],
[18.6],
[11.6],
[60],
[57.9],
[17.1],
[7.1],
[14.5],
[186.3],
[31.4],
[5.5],
[2.8],
[65],
[55.4],
[16.1],
[8.1],
[88.9],
[75.1],
[128.4],
[14.6],
[17.1],
[2.8],
[6.9],
[7.7],
[97],
[9],
[5.9],
[10.2],
[1.7],
[138.8],
[49.9],
[1.7],
[1.9],
[5.8],
[10],
[4.3],
[12.6],
[2.9],
[14.1],
[174.5],
[76],
[11.5],
[150.4],
[5.5],
[3.2],
[3.1],
[6.4],
[20.7],
[86],
[2.4],
[6.9],
[57.7],
[40.8],
[21.6],
[11.9],
[10.1],
[56.6],
[120],
[35.1],
[14.8],
[4.5],
[6.7],
[109.4],
[1.7],
[7.3],
[2.3],
[2.8],
[4.4],
[20.8],
[14.6],
[1.7],
[5.2],
[6.8],
[8.3],
[39],
[2.3],
[6.1],
[53.5],
[6.9],
[2.6],
[13],
[410],
[51.4],
[1.8],
[19.4],
[82.4],
[168.2],
[6.8],
[15.9]
]
}
},
config = {
"graphType": "Map",
"topoJSON": "https://www.canvasxpress.org/data/maps/WORLD.json",
"mapId": "worldCo2",
"theme": "stata",
"colorBy": "Cumulative CO2 (Gt)",
"colorSpectrum": ["#2166ac", "#92c5de", "#f7f7f7", "#f4a582", "#b2182b"],
"colorSpectrumBreaksMethod": "quantile",
"title": "Who has emitted the most CO2?",
"subtitle": "Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
"legendPosition": "bottomLeft",
"legendInside": True,
"showLegendTitle": True,
"mapColor": "#e0e0e0",
"decorations": {
"marker": [
{
"coords": [37, -98],
"shape": "none",
"type": "curved",
"fontSize": 12,
"text": "The U.S. has emitted\n1.75x as much CO2\nas China since 1750",
"x": 0.13,
"y": 0.66
}
]
}
},
width = 760,
height = 560
)
# 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 = "map22",
data = {
"y": {
"vars": ["AFG", "AGO", "ALB", "ARE", "ARG", "ARM", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BFA", "BGD", "BGR", "BIH", "BLR", "BOL", "BRA", "BWA", "CAF", "CAN", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COL", "CRI", "CUB", "CZE", "DEU", "DNK", "DOM", "DZA", "ECU", "EGY", "ESP", "EST", "ETH", "FIN", "FRA", "GAB", "GBR", "GEO", "GHA", "GIN", "GRC", "GTM", "HND", "HRV", "HTI", "HUN", "IDN", "IND", "IRL", "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JOR", "JPN", "KAZ", "KEN", "KGZ", "KHM", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LKA", "LSO", "LTU", "LVA", "MAR", "MDG", "MEX", "MLI", "MMR", "MNG", "MOZ", "MRT", "MWI", "MYS", "NAM", "NER", "NGA", "NIC", "NLD", "NOR", "NPL", "NZL", "OMN", "PAK", "PAN", "PER", "PHL", "PNG", "POL", "PRK", "PRT", "PRY", "QAT", "ROU", "RUS", "RWA", "SAU", "SDN", "SEN", "SLE", "SLV", "SOM", "SRB", "SVK", "SVN", "SWE", "SYR", "TCD", "TGO", "THA", "TJK", "TKM", "TUN", "TUR", "TZA", "UGA", "UKR", "URY", "USA", "UZB", "VEN", "VNM", "YEM", "ZAF", "ZMB", "ZWE"],
"smps": ["Cumulative CO2 (Gt)"],
"data": [
[19.2],
[196.7],
[1.8],
[56.6],
[4.1],
[27.2],
[3.7],
[163.2],
[34.8],
[17.5],
[28.8],
[74],
[4.7],
[58.1],
[139.6],
[113.1],
[165.5],
[4.8],
[28.9],
[60],
[2.7],
[15.7],
[3.4],
[38.5],
[235],
[60.7],
[7.2],
[39.6],
[15.7],
[26.1],
[173.1],
[9],
[9],
[92],
[3],
[127.5],
[131.7],
[2.9],
[4.6],
[25.1],
[46],
[7.3],
[98.9],
[3.7],
[4.6],
[78],
[1.8],
[24.6],
[190.8],
[125.5],
[2],
[6.7],
[7],
[117.7],
[18.6],
[11.6],
[60],
[57.9],
[17.1],
[7.1],
[14.5],
[186.3],
[31.4],
[5.5],
[2.8],
[65],
[55.4],
[16.1],
[8.1],
[88.9],
[75.1],
[128.4],
[14.6],
[17.1],
[2.8],
[6.9],
[7.7],
[97],
[9],
[5.9],
[10.2],
[1.7],
[138.8],
[49.9],
[1.7],
[1.9],
[5.8],
[10],
[4.3],
[12.6],
[2.9],
[14.1],
[174.5],
[76],
[11.5],
[150.4],
[5.5],
[3.2],
[3.1],
[6.4],
[20.7],
[86],
[2.4],
[6.9],
[57.7],
[40.8],
[21.6],
[11.9],
[10.1],
[56.6],
[120],
[35.1],
[14.8],
[4.5],
[6.7],
[109.4],
[1.7],
[7.3],
[2.3],
[2.8],
[4.4],
[20.8],
[14.6],
[1.7],
[5.2],
[6.8],
[8.3],
[39],
[2.3],
[6.1],
[53.5],
[6.9],
[2.6],
[13],
[410],
[51.4],
[1.8],
[19.4],
[82.4],
[168.2],
[6.8],
[15.9]
]
}
},
config = {
"graphType": "Map",
"topoJSON": "https://www.canvasxpress.org/data/maps/WORLD.json",
"mapId": "worldCo2",
"theme": "stata",
"colorBy": "Cumulative CO2 (Gt)",
"colorSpectrum": ["#2166ac", "#92c5de", "#f7f7f7", "#f4a582", "#b2182b"],
"colorSpectrumBreaksMethod": "quantile",
"title": "Who has emitted the most CO2?",
"subtitle": "Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
"legendPosition": "bottomLeft",
"legendInside": True,
"showLegendTitle": True,
"mapColor": "#e0e0e0",
"decorations": {
"marker": [
{
"coords": [37, -98],
"shape": "none",
"type": "curved",
"fontSize": 12,
"text": "The U.S. has emitted\n1.75x as much CO2\nas China since 1750",
"x": 0.13,
"y": 0.66
}
]
}
},
width = 760,
height = 560
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["AFG", "AGO", "ALB", "ARE", "ARG", "ARM", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BFA", "BGD", "BGR", "BIH", "BLR", "BOL", "BRA", "BWA", "CAF", "CAN", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COL", "CRI", "CUB", "CZE", "DEU", "DNK", "DOM", "DZA", "ECU", "EGY", "ESP", "EST", "ETH", "FIN", "FRA", "GAB", "GBR", "GEO", "GHA", "GIN", "GRC", "GTM", "HND", "HRV", "HTI", "HUN", "IDN", "IND", "IRL", "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JOR", "JPN", "KAZ", "KEN", "KGZ", "KHM", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LKA", "LSO", "LTU", "LVA", "MAR", "MDG", "MEX", "MLI", "MMR", "MNG", "MOZ", "MRT", "MWI", "MYS", "NAM", "NER", "NGA", "NIC", "NLD", "NOR", "NPL", "NZL", "OMN", "PAK", "PAN", "PER", "PHL", "PNG", "POL", "PRK", "PRT", "PRY", "QAT", "ROU", "RUS", "RWA", "SAU", "SDN", "SEN", "SLE", "SLV", "SOM", "SRB", "SVK", "SVN", "SWE", "SYR", "TCD", "TGO", "THA", "TJK", "TKM", "TUN", "TUR", "TZA", "UGA", "UKR", "URY", "USA", "UZB", "VEN", "VNM", "YEM", "ZAF", "ZMB", "ZWE"],
"smps" => ["Cumulative CO2 (Gt)"],
"data" => [
[19.2],
[196.7],
[1.8],
[56.6],
[4.1],
[27.2],
[3.7],
[163.2],
[34.8],
[17.5],
[28.8],
[74],
[4.7],
[58.1],
[139.6],
[113.1],
[165.5],
[4.8],
[28.9],
[60],
[2.7],
[15.7],
[3.4],
[38.5],
[235],
[60.7],
[7.2],
[39.6],
[15.7],
[26.1],
[173.1],
[9],
[9],
[92],
[3],
[127.5],
[131.7],
[2.9],
[4.6],
[25.1],
[46],
[7.3],
[98.9],
[3.7],
[4.6],
[78],
[1.8],
[24.6],
[190.8],
[125.5],
[2],
[6.7],
[7],
[117.7],
[18.6],
[11.6],
[60],
[57.9],
[17.1],
[7.1],
[14.5],
[186.3],
[31.4],
[5.5],
[2.8],
[65],
[55.4],
[16.1],
[8.1],
[88.9],
[75.1],
[128.4],
[14.6],
[17.1],
[2.8],
[6.9],
[7.7],
[97],
[9],
[5.9],
[10.2],
[1.7],
[138.8],
[49.9],
[1.7],
[1.9],
[5.8],
[10],
[4.3],
[12.6],
[2.9],
[14.1],
[174.5],
[76],
[11.5],
[150.4],
[5.5],
[3.2],
[3.1],
[6.4],
[20.7],
[86],
[2.4],
[6.9],
[57.7],
[40.8],
[21.6],
[11.9],
[10.1],
[56.6],
[120],
[35.1],
[14.8],
[4.5],
[6.7],
[109.4],
[1.7],
[7.3],
[2.3],
[2.8],
[4.4],
[20.8],
[14.6],
[1.7],
[5.2],
[6.8],
[8.3],
[39],
[2.3],
[6.1],
[53.5],
[6.9],
[2.6],
[13],
[410],
[51.4],
[1.8],
[19.4],
[82.4],
[168.2],
[6.8],
[15.9]
]
)
);
graphType = "Map",
topoJSON = "https://www.canvasxpress.org/data/maps/WORLD.json",
mapId = "worldCo2",
theme = "stata",
colorBy = "Cumulative CO2 (Gt)",
colorSpectrum = ["#2166ac", "#92c5de", "#f7f7f7", "#f4a582", "#b2182b"],
colorSpectrumBreaksMethod = "quantile",
title = "Who has emitted the most CO2?",
subtitle = "Illustrative cumulative emissions, gigatonnes. Synthetic data for illustration",
legendPosition = "bottomLeft",
legendInside = true,
showLegendTitle = true,
mapColor = "#e0e0e0",
decorations = Dict(
"marker" => [
Dict(
"coords" => [37, -98],
"shape" => "none",
"type" => "curved",
"fontSize" => 12,
"text" => "The U.S. has emitted\n1.75x as much CO2\nas China since 1750",
"x" => 0.13,
"y" => 0.66
)
]
)
)


























