Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford

This notebook demonstrates histograms, bar charts, and pie charts.

Figures  12.10, 12.11, and 12.12 were created with this notebook.

See Chapter 12: Visualization of Empirical Data for details.

Updated May 2008

(* Load packages *)
Needs["BarCharts`"]
Needs["PieCharts`"]

(* Set the folder for output *)
(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];) 


(* Create data: men and women population in millions *)(men={3.8`,3.9`,3.7`,4.2`,3.9`,3.8`,2.5`,2.1`,0.5`,0.4`};) 
(women={3.2`,3.3`,3.35`,5.`,3.5`,3.8`,3.2`,3.`,2.`,1.1`};) 


(* Create a bar chart -- histogram of men/women in age categories *)(pic=BarChart[men,women,BarLabels->{"0-9","10-19","20-29","30-39","40-49","50-59","60-69","70-79","80-89","90+"},BarOrientation->Horizontal,BarSpacing->0.1`,BarGroupSpacing->0.5`,BarStyle->{GrayLevel[0.`],GrayLevel[0.7`]},PlotLabel->"2001 UK Population in Millions",BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11},ColorOutput->GrayLevel]) 

(* Output to postscript file *)
(Export["population_histogram.eps",pic];) 

(* Create a barchart in another style *)
(bcpic=BarChart[{2,2.5`,5,5.5`,5,3.5`},BarSpacing->0.1`,BarGroupSpacing->0.5`,BarLabels->{"Apr","May","Jun","Jul","Aug","Sep"},BarStyle->{GrayLevel[0.7`]},PlotLabel->"2008 Tourist Season Projected Profits in Millions",BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11},ColorOutput->GrayLevel]) 

(* Output to a postscript file *)

(Export["barchart.eps",bcpic];) 

(* Create a pie chart of ethnice groups *)
(ppic=PieChart[{45.4`,35.7`,9.3`,8.9`,0.7`},PieLabels->{"Hispanic 45.4%","White 35.7%","African American 9.3%","Asian/Pacific 8.9%","Other 0.7%"},PlotLabel->"2005 Population in Southern California",BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11},PieStyle->{GrayLevel[0.7`],GrayLevel[0.85`],GrayLevel[0.9`],GrayLevel[0.95`],GrayLevel[1.`]},ColorOutput->GrayLevel]) 


(* Output to poscript file *)
Export["piechart.eps",ppic];