Monthly climatogram: columns plus a line on two axes
Time series charts in CanvasXpress show how values change over calendar time: annual, monthly and daily series as lines, step lines, areas, columns and small multiples, with confidence bands, projections, shaded periods, event callouts, dual axes and direct end labels. These examples recreate editorial chart idioms (the Datawrapper reference set) with synthetic data and publication-style themes; every one of them is an ordinary Scatter2D, Line, Area, AreaLine, Bar, BarLine or Stacked configuration, so the same options apply to your own dated 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" : "BarLine",
"theme" : "classic",
"colorScheme" : "User",
"colors" : [
"#56B4E9",
"#D55E00"
],
"title" : "Wet winters, mild summers",
"subtitle" : "Monthly rainfall and mean air temperature at a synthetic temperate station",
"graphOrientation" : "vertical",
"xAxis" : [
"Rainfall (mm)"
],
"xAxis2" : [
"Mean temperature (°C)"
],
"xAxis2Show" : true,
"xAxisTitle" : "Rainfall (mm)",
"xAxis2Title" : "Temperature (°C)",
"lineThickness" : 3,
"lineType" : "spline",
"lineDecoration" : "symbol",
"dataPointSize" : 22,
"legendPosition" : "top",
"smpTitle" : "Month",
"smpTextRotate" : 90
}
// 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" : [
"Rainfall (mm)",
"Mean temperature (°C)"
],
"smps" : [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
"data" : [
[
52.16,
41.42,
46.51,
49.26,
61.91,
62.53,
48.12,
60.43,
58.51,
65.3,
63.72,
60.81
],
[
4.1,
5,
7.52,
9.49,
12.81,
16.13,
18.38,
18.15,
15.7,
11.45,
7.72,
5.19
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "BarLine",
"theme" : "classic",
"colorScheme" : "User",
"colors" : [
"#56B4E9",
"#D55E00"
],
"title" : "Wet winters, mild summers",
"subtitle" : "Monthly rainfall and mean air temperature at a synthetic temperate station",
"graphOrientation" : "vertical",
"xAxis" : [
"Rainfall (mm)"
],
"xAxis2" : [
"Mean temperature (°C)"
],
"xAxis2Show" : true,
"xAxisTitle" : "Rainfall (mm)",
"xAxis2Title" : "Temperature (°C)",
"lineThickness" : 3,
"lineType" : "spline",
"lineDecoration" : "symbol",
"dataPointSize" : 22,
"legendPosition" : "top",
"smpTitle" : "Month",
"smpTextRotate" : 90
}
// 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>
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 = "timeseries17",
data = {
"y": {
"vars": ["Rainfall (mm)", "Mean temperature (°C)"],
"smps": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"data": [
[52.16, 41.42, 46.51, 49.26, 61.91, 62.53, 48.12, 60.43, 58.51, 65.3, 63.72, 60.81],
[4.1, 5, 7.52, 9.49, 12.81, 16.13, 18.38, 18.15, 15.7, 11.45, 7.72, 5.19]
]
}
},
config = {
"graphType": "BarLine",
"theme": "classic",
"colorScheme": "User",
"colors": ["#56B4E9", "#D55E00"],
"title": "Wet winters, mild summers",
"subtitle": "Monthly rainfall and mean air temperature at a synthetic temperate station",
"graphOrientation": "vertical",
"xAxis": ["Rainfall (mm)"],
"xAxis2": ["Mean temperature (°C)"],
"xAxis2Show": True,
"xAxisTitle": "Rainfall (mm)",
"xAxis2Title": "Temperature (°C)",
"lineThickness": 3,
"lineType": "spline",
"lineDecoration": "symbol",
"dataPointSize": 22,
"legendPosition": "top",
"smpTitle": "Month",
"smpTextRotate": 90
},
width = 760,
height = 520
)
# 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 = "timeseries17",
data = {
"y": {
"vars": ["Rainfall (mm)", "Mean temperature (°C)"],
"smps": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"data": [
[52.16, 41.42, 46.51, 49.26, 61.91, 62.53, 48.12, 60.43, 58.51, 65.3, 63.72, 60.81],
[4.1, 5, 7.52, 9.49, 12.81, 16.13, 18.38, 18.15, 15.7, 11.45, 7.72, 5.19]
]
}
},
config = {
"graphType": "BarLine",
"theme": "classic",
"colorScheme": "User",
"colors": ["#56B4E9", "#D55E00"],
"title": "Wet winters, mild summers",
"subtitle": "Monthly rainfall and mean air temperature at a synthetic temperate station",
"graphOrientation": "vertical",
"xAxis": ["Rainfall (mm)"],
"xAxis2": ["Mean temperature (°C)"],
"xAxis2Show": True,
"xAxisTitle": "Rainfall (mm)",
"xAxis2Title": "Temperature (°C)",
"lineThickness": 3,
"lineType": "spline",
"lineDecoration": "symbol",
"dataPointSize": 22,
"legendPosition": "top",
"smpTitle": "Month",
"smpTextRotate": 90
},
width = 760,
height = 520
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Rainfall (mm)", "Mean temperature (°C)"],
"smps" => ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"data" => [
[52.16, 41.42, 46.51, 49.26, 61.91, 62.53, 48.12, 60.43, 58.51, 65.3, 63.72, 60.81],
[4.1, 5, 7.52, 9.49, 12.81, 16.13, 18.38, 18.15, 15.7, 11.45, 7.72, 5.19]
]
)
);
graphType = "BarLine",
theme = "classic",
colorScheme = "User",
colors = ["#56B4E9", "#D55E00"],
title = "Wet winters, mild summers",
subtitle = "Monthly rainfall and mean air temperature at a synthetic temperate station",
graphOrientation = "vertical",
xAxis = ["Rainfall (mm)"],
xAxis2 = ["Mean temperature (°C)"],
xAxis2Show = true,
xAxisTitle = "Rainfall (mm)",
xAxis2Title = "Temperature (°C)",
lineThickness = 3,
lineType = "spline",
lineDecoration = "symbol",
dataPointSize = 22,
legendPosition = "top",
smpTitle = "Month",
smpTextRotate = 90
)
























