Two diverging series on dual 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.


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" : "AreaLine",
         "theme" : "paulTol",
         "colorScheme" : "User",
         "colors" : [
            "#BB5566",
            "#004488"
         ],
         "title" : "Rising CO2, shrinking ice",
         "subtitle" : "Atmospheric CO2 and Arctic sea-ice extent, synthetic series",
         "graphOrientation" : "vertical",
         "xAxis" : [
            "Sea-ice extent (million km²)"
         ],
         "xAxis2" : [
            "CO2 (ppm)"
         ],
         "xAxisShow" : true,
         "xAxis2Show" : true,
         "xAxisTitle" : "Sea-ice extent (million km²)",
         "xAxis2Title" : "CO2 (ppm)",
         "objectColorTransparency" : 0.35,
         "setMinX" : 0,
         "setMaxX" : 9,
         "setMinX2" : 300,
         "setMaxX2" : 450,
         "lineThickness" : 3,
         "lineDecoration" : "symbol",
         "dataPointSize" : 16,
         "legendPosition" : "top",
         "smpTitle" : "Year",
         "smpLabelInterval" : 5,
         "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" : [
               "CO2 (ppm)",
               "Sea-ice extent (million km²)"
            ],
            "smps" : [
               "1985 ",
               "1986 ",
               "1987 ",
               "1988 ",
               "1989 ",
               "1990 ",
               "1991 ",
               "1992 ",
               "1993 ",
               "1994 ",
               "1995 ",
               "1996 ",
               "1997 ",
               "1998 ",
               "1999 ",
               "2000 ",
               "2001 ",
               "2002 ",
               "2003 ",
               "2004 ",
               "2005 ",
               "2006 ",
               "2007 ",
               "2008 ",
               "2009 ",
               "2010 ",
               "2011 ",
               "2012 ",
               "2013 ",
               "2014 ",
               "2015 ",
               "2016 ",
               "2017 ",
               "2018 ",
               "2019 ",
               "2020 ",
               "2021 ",
               "2022 ",
               "2023 ",
               "2024 "
            ],
            "data" : [
               [
                  345.41,
                  347.94,
                  350.47,
                  353.13,
                  355.15,
                  356.65,
                  357.97,
                  359.26,
                  361.11,
                  362.95,
                  364.96,
                  367.91,
                  370.41,
                  373.32,
                  375.79,
                  378.41,
                  380.03,
                  381.51,
                  382.86,
                  384.57,
                  386.06,
                  388.09,
                  390.41,
                  392.87,
                  395.86,
                  398.84,
                  401.07,
                  403.25,
                  405.46,
                  407.1,
                  408.1,
                  409.49,
                  410.98,
                  413.35,
                  415.41,
                  417.95,
                  421.31,
                  423.84,
                  426.59,
                  428.87
               ],
               [
                  7.47,
                  7.49,
                  7.52,
                  7.5,
                  7.41,
                  7.45,
                  7.14,
                  7.05,
                  6.85,
                  6.76,
                  6.4,
                  6.28,
                  6.13,
                  6.27,
                  6.01,
                  6.08,
                  6.28,
                  6.19,
                  6.37,
                  6.41,
                  6.4,
                  6.19,
                  6.22,
                  6.14,
                  5.78,
                  5.67,
                  5.61,
                  5.24,
                  5.11,
                  4.91,
                  5.02,
                  4.97,
                  4.83,
                  4.98,
                  5.14,
                  5.15,
                  5.07,
                  5.22,
                  5.11,
                  5.06
               ]
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "AreaLine",
         "theme" : "paulTol",
         "colorScheme" : "User",
         "colors" : [
            "#BB5566",
            "#004488"
         ],
         "title" : "Rising CO2, shrinking ice",
         "subtitle" : "Atmospheric CO2 and Arctic sea-ice extent, synthetic series",
         "graphOrientation" : "vertical",
         "xAxis" : [
            "Sea-ice extent (million km²)"
         ],
         "xAxis2" : [
            "CO2 (ppm)"
         ],
         "xAxisShow" : true,
         "xAxis2Show" : true,
         "xAxisTitle" : "Sea-ice extent (million km²)",
         "xAxis2Title" : "CO2 (ppm)",
         "objectColorTransparency" : 0.35,
         "setMinX" : 0,
         "setMaxX" : 9,
         "setMinX2" : 300,
         "setMaxX2" : 450,
         "lineThickness" : 3,
         "lineDecoration" : "symbol",
         "dataPointSize" : 16,
         "legendPosition" : "top",
         "smpTitle" : "Year",
         "smpLabelInterval" : 5,
         "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 = "timeseries18",
    data = {
      "y": {
        "vars": ["CO2 (ppm)", "Sea-ice extent (million km²)"],
        "smps": ["1985 ", "1986 ", "1987 ", "1988 ", "1989 ", "1990 ", "1991 ", "1992 ", "1993 ", "1994 ", "1995 ", "1996 ", "1997 ", "1998 ", "1999 ", "2000 ", "2001 ", "2002 ", "2003 ", "2004 ", "2005 ", "2006 ", "2007 ", "2008 ", "2009 ", "2010 ", "2011 ", "2012 ", "2013 ", "2014 ", "2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
        "data": [
          [345.41, 347.94, 350.47, 353.13, 355.15, 356.65, 357.97, 359.26, 361.11, 362.95, 364.96, 367.91, 370.41, 373.32, 375.79, 378.41, 380.03, 381.51, 382.86, 384.57, 386.06, 388.09, 390.41, 392.87, 395.86, 398.84, 401.07, 403.25, 405.46, 407.1, 408.1, 409.49, 410.98, 413.35, 415.41, 417.95, 421.31, 423.84, 426.59, 428.87],
          [7.47, 7.49, 7.52, 7.5, 7.41, 7.45, 7.14, 7.05, 6.85, 6.76, 6.4, 6.28, 6.13, 6.27, 6.01, 6.08, 6.28, 6.19, 6.37, 6.41, 6.4, 6.19, 6.22, 6.14, 5.78, 5.67, 5.61, 5.24, 5.11, 4.91, 5.02, 4.97, 4.83, 4.98, 5.14, 5.15, 5.07, 5.22, 5.11, 5.06]
        ]
      }
    },
    config = {
      "graphType": "AreaLine",
      "theme": "paulTol",
      "colorScheme": "User",
      "colors": ["#BB5566", "#004488"],
      "title": "Rising CO2, shrinking ice",
      "subtitle": "Atmospheric CO2 and Arctic sea-ice extent, synthetic series",
      "graphOrientation": "vertical",
      "xAxis": ["Sea-ice extent (million km²)"],
      "xAxis2": ["CO2 (ppm)"],
      "xAxisShow": True,
      "xAxis2Show": True,
      "xAxisTitle": "Sea-ice extent (million km²)",
      "xAxis2Title": "CO2 (ppm)",
      "objectColorTransparency": 0.35,
      "setMinX": 0,
      "setMaxX": 9,
      "setMinX2": 300,
      "setMaxX2": 450,
      "lineThickness": 3,
      "lineDecoration": "symbol",
      "dataPointSize": 16,
      "legendPosition": "top",
      "smpTitle": "Year",
      "smpLabelInterval": 5,
      "smpTextRotate": 90
    },
    width = 760,
    height = 520
  )

  # 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 = "timeseries18",
    data = {
      "y": {
        "vars": ["CO2 (ppm)", "Sea-ice extent (million km²)"],
        "smps": ["1985 ", "1986 ", "1987 ", "1988 ", "1989 ", "1990 ", "1991 ", "1992 ", "1993 ", "1994 ", "1995 ", "1996 ", "1997 ", "1998 ", "1999 ", "2000 ", "2001 ", "2002 ", "2003 ", "2004 ", "2005 ", "2006 ", "2007 ", "2008 ", "2009 ", "2010 ", "2011 ", "2012 ", "2013 ", "2014 ", "2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
        "data": [
          [345.41, 347.94, 350.47, 353.13, 355.15, 356.65, 357.97, 359.26, 361.11, 362.95, 364.96, 367.91, 370.41, 373.32, 375.79, 378.41, 380.03, 381.51, 382.86, 384.57, 386.06, 388.09, 390.41, 392.87, 395.86, 398.84, 401.07, 403.25, 405.46, 407.1, 408.1, 409.49, 410.98, 413.35, 415.41, 417.95, 421.31, 423.84, 426.59, 428.87],
          [7.47, 7.49, 7.52, 7.5, 7.41, 7.45, 7.14, 7.05, 6.85, 6.76, 6.4, 6.28, 6.13, 6.27, 6.01, 6.08, 6.28, 6.19, 6.37, 6.41, 6.4, 6.19, 6.22, 6.14, 5.78, 5.67, 5.61, 5.24, 5.11, 4.91, 5.02, 4.97, 4.83, 4.98, 5.14, 5.15, 5.07, 5.22, 5.11, 5.06]
        ]
      }
    },
    config = {
      "graphType": "AreaLine",
      "theme": "paulTol",
      "colorScheme": "User",
      "colors": ["#BB5566", "#004488"],
      "title": "Rising CO2, shrinking ice",
      "subtitle": "Atmospheric CO2 and Arctic sea-ice extent, synthetic series",
      "graphOrientation": "vertical",
      "xAxis": ["Sea-ice extent (million km²)"],
      "xAxis2": ["CO2 (ppm)"],
      "xAxisShow": True,
      "xAxis2Show": True,
      "xAxisTitle": "Sea-ice extent (million km²)",
      "xAxis2Title": "CO2 (ppm)",
      "objectColorTransparency": 0.35,
      "setMinX": 0,
      "setMaxX": 9,
      "setMinX2": 300,
      "setMaxX2": 450,
      "lineThickness": 3,
      "lineDecoration": "symbol",
      "dataPointSize": 16,
      "legendPosition": "top",
      "smpTitle": "Year",
      "smpLabelInterval": 5,
      "smpTextRotate": 90
    },
    width = 760,
    height = 520
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["CO2 (ppm)", "Sea-ice extent (million km²)"],
    "smps" => ["1985 ", "1986 ", "1987 ", "1988 ", "1989 ", "1990 ", "1991 ", "1992 ", "1993 ", "1994 ", "1995 ", "1996 ", "1997 ", "1998 ", "1999 ", "2000 ", "2001 ", "2002 ", "2003 ", "2004 ", "2005 ", "2006 ", "2007 ", "2008 ", "2009 ", "2010 ", "2011 ", "2012 ", "2013 ", "2014 ", "2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
    "data" => [
      [345.41, 347.94, 350.47, 353.13, 355.15, 356.65, 357.97, 359.26, 361.11, 362.95, 364.96, 367.91, 370.41, 373.32, 375.79, 378.41, 380.03, 381.51, 382.86, 384.57, 386.06, 388.09, 390.41, 392.87, 395.86, 398.84, 401.07, 403.25, 405.46, 407.1, 408.1, 409.49, 410.98, 413.35, 415.41, 417.95, 421.31, 423.84, 426.59, 428.87],
      [7.47, 7.49, 7.52, 7.5, 7.41, 7.45, 7.14, 7.05, 6.85, 6.76, 6.4, 6.28, 6.13, 6.27, 6.01, 6.08, 6.28, 6.19, 6.37, 6.41, 6.4, 6.19, 6.22, 6.14, 5.78, 5.67, 5.61, 5.24, 5.11, 4.91, 5.02, 4.97, 4.83, 4.98, 5.14, 5.15, 5.07, 5.22, 5.11, 5.06]
    ]
  )
);
  graphType = "AreaLine",
  theme = "paulTol",
  colorScheme = "User",
  colors = ["#BB5566", "#004488"],
  title = "Rising CO2, shrinking ice",
  subtitle = "Atmospheric CO2 and Arctic sea-ice extent, synthetic series",
  graphOrientation = "vertical",
  xAxis = ["Sea-ice extent (million km²)"],
  xAxis2 = ["CO2 (ppm)"],
  xAxisShow = true,
  xAxis2Show = true,
  xAxisTitle = "Sea-ice extent (million km²)",
  xAxis2Title = "CO2 (ppm)",
  objectColorTransparency = 0.35,
  setMinX = 0,
  setMaxX = 9,
  setMinX2 = 300,
  setMaxX2 = 450,
  lineThickness = 3,
  lineDecoration = "symbol",
  dataPointSize = 16,
  legendPosition = "top",
  smpTitle = "Year",
  smpLabelInterval = 5,
  smpTextRotate = 90
)
⇧