Lollipop Chart

A lollipop plot is basically a barplot, where the bar is transformed in a line and a dot. It shows the relationship between a numeric and a categoric variable. However it is more appealing and convey as well the information. It is especially useful when you have several bars of the same height: it avoids to have a cluttered figure and a Moiré effect. The Cleveland dot plot is a handy variation, allowing to compare the value of 2 numeric values for each group.



Color Themes


{
   "x" : {
      "Color" : ["A","B","C","D","E","F"]
   },
   "y" : {
      "data" : [
        [-40,-85,-60,50,75,100]
      ],
      "smps" : ["Engineering","Biology","Computer","Psycology","Education","Health"],
      "vars" : ["Var1"]
   }
}
{
   "backgroundType" : "solid",
   "barLollipopFactor" : 1.5,
   "barLollipopOpen" : "true",
   "barPath" : "true",
   "barPathColor" : "rgb(225,225,225)",
   "barPathTransparency" : "1",
   "barType" : "lollipop",
   "colorBy" : "Color",
   "colorScheme" : "GGPlot",
   "graphType" : "Bar",
   "marginBottom" : "50",
   "marginLeft" : "50",
   "marginRight" : "50",
   "marginTop" : "50",
   "maxTextSize" : "80",
   "objectBorderColor" : "rgba(0,0,0,0)",
   "setMaxX" : "150",
   "setMinX" : "-150",
   "showDataValues" : "true",
   "showLegend" : "false",
   "smpLabelScaleFontFactor" : "2",
   "title" : "Occupations",
   "xAxis2Show" : "false",
   "xAxisMajorTicks" : "false",
   "xAxisMinorTicks" : "false",
   "xAxisShow" : "false"
}
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-lollipop2-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-lollipop2-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  smpAnnot=x,
  backgroundType="solid",
  barLollipopFactor=1.5,
  barLollipopOpen=TRUE,
  barPath=TRUE,
  barPathColor="rgb(225,225,225)",
  barPathTransparency=1,
  barType="lollipop",
  colorBy="Color",
  colorScheme="GGPlot",
  graphType="Bar",
  marginBottom=50,
  marginLeft=50,
  marginRight=50,
  marginTop=50,
  maxTextSize=80,
  objectBorderColor="rgba(0,0,0,0)",
  setMaxX=150,
  setMinX=-150,
  showDataValues=TRUE,
  showLegend=FALSE,
  smpLabelScaleFontFactor=2,
  title="Occupations",
  xAxis2Show=FALSE,
  xAxisMajorTicks=FALSE,
  xAxisMinorTicks=FALSE,
  xAxisShow=FALSE
)