A barplot shows the relationship between a numeric and a categoric variable. Each entity of the categoric variable is represented as a bar. The size of the bar represents its numeric value. Barplot is sometimes described as a boring way to visualize information. However it is probably the most efficient way to show this kind of data. Ordering bars and providing good annotation are often necessary.
<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" : { "data" : [ [25.6,13.2,12.1,8.5,6.8,6.4,6.1,5.5,4.1,3.8] ], "smps" : ["Lung, trachea, and bronchus","Colon and rectum","Stomach","Breast","Esophageal","Pancreas","Liver","Prostate","Leukmia","Cervical"], "vars" : ["Number of Deaths per 100000 people"] } } // Create the configuration for the graph var config = { "citation":"Data source: IHME, Global Burden of Disease (2024)", "citationScaleFontFactor":0.7, "graphOrientation":"horizontal", "graphType":"Bar", "maxSmpStringLen":"50", "showDataValues":true, "showLegend":false, "subtitle":" Estimated number of deaths from different types of cancer per 100,000 people.", "subtitleScaleFontFactor":0.6, "theme":"CanvasXpress", "title":"Cancer crude death rate by type, World, 2021", "widthFactor":"2", "xAxisGridMajorShow":false, "xAxisShow":false } // 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-cancerDeathByType2021-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE) canvasXpress( data=y, citation="Data source: IHME, Global Burden of Disease (2024)", citationScaleFontFactor=0.7, graphOrientation="horizontal", graphType="Bar", maxSmpStringLen=50, showDataValues=TRUE, showLegend=FALSE, subtitle=" Estimated number of deaths from different types of cancer per 100,000 people.", subtitleScaleFontFactor=0.6, theme="CanvasXpress", title="Cancer crude death rate by type, World, 2021", widthFactor=2, xAxisGridMajorShow=FALSE, xAxisShow=FALSE )