Bar plots are useful for comparing data in an easy-to-read visualization. The BARPLOT function allows you to quickly create bar plots and define colors, styles, and annotations. The bar plot shown below displays average monthly temperature data for two different years.
The code shown below creates the graphic shown above. You can copy the entire block and paste it into the IDL command line to run it. The properties used are explained in detail after the example code.
TEMP08=[30, 34, 38, 47, 57, 67, 73, 71, 63, 52, 39, 33]
TEMP09=[28, 36, 42, 47, 55, 62, 70, 75, 66, 47, 44, 32]
months=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
b1 = BARPLOT(months, TEMP08, index=0, NBARS=2, FILL_COLOR='gold', $
YRANGE=[0, 80], YMINOR=0, YTITLE='Temperature Fahrenheit', $
XTITLE='Months', TITLE='Average Monthly Temperature')
b2 = BARPLOT(months, TEMP09, INDEX=1, NBARS=2, FILL_COLOR='blue', /OVERPLOT)
text08 = TEXT(2,75,'2008', /CURRENT, COLOR='gold', /DATA)
text09 = TEXT(2,70,'2009', /CURRENT, COLOR='blue', /DATA)
Resources