Dotplot Chart

According to William S. Cleveland dotplots are an alternative to the bar chart, in which dots are used to depict the quantitative values (e.g. counts) associated with categorical variables.


Example Color Themes

Example Fonts



Show Code

Tools

<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 = {
       "x" : {
          "Factor1" : ["Lev : 1","Lev : 2","Lev : 3","Lev : 1","Lev : 2","Lev : 3"],
          "Factor2" : ["Lev : A","Lev : B","Lev : A","Lev : B","Lev : A","Lev : B"],
          "Factor3" : ["Lev : X","Lev : X","Lev : Y","Lev : Y","Lev : Z","Lev : Z"],
          "Factor4" : [5,10,15,20,25,30],
          "Factor5" : [8,16,24,32,40,48],
          "Factor6" : [10,20,30,40,50,60]
       },
       "y" : {
          "data" : [
            [5,10,25,40,45,50],
            [95,80,75,70,55,40],
            [25,30,45,60,65,70],
            [55,40,35,30,15,1]
          ],
          "desc" : ["Magnitude1","Magnitude2"],
          "smps" : ["S1","S2","S3","S4","S5","S6"],
          "vars" : ["V1","V2","V3","V4"]
       },
       "z" : {
          "Annt1" : ["Desc : 1","Desc : 2","Desc : 3","Desc : 4"],
          "Annt2" : ["Desc : A","Desc : B","Desc : A","Desc : B"],
          "Annt3" : ["Desc : X","Desc : X","Desc : Y","Desc : Y"],
          "Annt4" : [5,10,15,20],
          "Annt5" : [8,16,24,32],
          "Annt6" : [10,20,30,40]
       }
    }
    
    
    // Create the configuration for the graph
    var config = {
       "graphOrientation":"vertical",
       "graphType":"Dotplot",
       "lineType":"spline",
       "showSmpOverlaysLegend":true,
       "smpOverlayProperties":{
          "Factor4":{
             "color":"blue",
             "showLegend":true,
             "thickness":50,
             "type":"Bar"
          },
          "Factor5":{
             "color":"grey",
             "showLegend":true,
             "thickness":50,
             "type":"Bar"
          },
          "Factor6":{
             "color":"red",
             "showLegend":true,
             "thickness":50,
             "type":"Bar"
          }
       },
       "smpOverlays":[
          "Factor1",
          "Factor2",
          "Factor3"
       ],
       "smpTextRotate":"45",
       "smpTitle":"Collection of Samples",
       "smpTitleFontStyle":"italic",
       "subtitle":"Random Data",
       "theme":"CanvasXpress",
       "title":"Dotplot Graph",
       "xAxisTickFormat":"%.0f Mil."
    }
    

    // Call the CanvasXpress function to create the graph
    var cX = new CanvasXpress("canvasId", data, config);


  </script>

</body>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-generic-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
x=read.table("https://www.canvasxpress.org/data/cX-generic-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
z=read.table("https://www.canvasxpress.org/data/cX-generic-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  smpAnnot=x,
  varAnnot=z,
  graphOrientation="vertical",
  graphType="Dotplot",
  lineType="spline",
  showSmpOverlaysLegend=TRUE,
  smpOverlayProperties=list(Factor4=list(color="blue", showLegend=TRUE, thickness=50, type="Bar"), Factor5=list(color="grey", showLegend=TRUE, thickness=50, type="Bar"), Factor6=list(color="red", showLegend=TRUE, thickness=50, type="Bar")),
  smpOverlays=list("Factor1", "Factor2", "Factor3"),
  smpTextRotate=45,
  smpTitle="Collection of Samples",
  smpTitleFontStyle="italic",
  subtitle="Random Data",
  theme="CanvasXpress",
  title="Dotplot Graph",
  xAxisTickFormat="%.0f Mil."
)