<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Dear NCL Users</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I am trying to plot a bar chart with year and months on the X-axis and am struggling to do so correctly.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I would also like to choose some years and months to be grey instead of black to show certainty levels. I am trying to make a similar plot to the one below:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<img style="max-width:100%" class="ContentPasted2 w-770 h-417" size="24966" contenttype="image/png" data-outlook-trace="F:1|T:1" src="cid:0ba8b8f1-2012-4b28-8d87-b13e4017b864"><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
This is what I currently have:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<img style="max-width:100%" class="ContentPasted1 w-1105 h-768" size="64237" contenttype="image/png" data-outlook-trace="F:1|T:1" src="cid:292cb285-6cd1-464e-b5d0-933539d55edb"><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Any help would be greatly appreciated!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Kindest Regards</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Melissa</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Code:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div class="ContentPasted3">;************************************************
<div class="ContentPasted3">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
</div>
<div class="ContentPasted3">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
</div>
<div class="ContentPasted3">;************************************************</div>
<div class="ContentPasted3">begin</div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3">;************************************************</div>
<div class="ContentPasted3">; plotting</div>
<div class="ContentPasted3">;************************************************</div>
<div class="ContentPasted3"> wks = gsn_open_wks("X11","Mpwapwa_Index") </div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3"> res = True </div>
<div class="ContentPasted3"> res@gsnMaximize = True</div>
<div class="ContentPasted3"> res@tiXAxisString = "Year & Month" ; x-axis label</div>
<div class="ContentPasted3"> res@tiYAxisString = "Precipitation Index" ; y-axis label</div>
<div class="ContentPasted3"> res@gsnXYBarChart = True</div>
<div class="ContentPasted3"> res@gsnXYBarChartBarWidth = 0.1</div>
<div class="ContentPasted3"> res@gsnYRefLine = 0 ; reference line
</div>
<div class="ContentPasted3"> res@tiMainString = "Mpwapwa"</div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3"> res@trYMinF = -3.5 ; min level</div>
<div class="ContentPasted3"> res@trYMaxF = 3.5 ; max level</div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3"> res@vpWidthF = 1.5 ; Make the plot wider than it
</div>
<div class="ContentPasted3"> res@vpHeightF = 0.75 ; is high.</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> res@gsnDraw = False ; do not draw the plot</div>
<div class="ContentPasted3"> res@gsnFrame = False </div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3">;Years and Months </div>
<div class="ContentPasted3">x = (/185501, 185502, 185503, 185504, 185505, 185506, 185507, 185508, 185509, 185510, 185511, 185512, 185601, 185602, 185603, 185604, 185605, 185606, 185607, 185608, 185609, 185610, 185611, 185612, 185701, 185702, 185703, 185704, 185705, 185706, 185707, 185708, 185709, 185710, 185711, 185712, 185801, 185802, 185803, 185804, 185805, 185806, 185807, 185808, 185809, 185810, 185811, 185812, 185901, 185902, 185903, 185904, 185905, 185906, 185907, 185908, 185909, 185910, 185911, 185912, 186001, 186002, 186003, 186004, 186005, 186006, 186007, 186008, 186009, 186010, 186011, 186012, 186101, 186102, 186103, 186104, 186105, 186106, 186107, 186108, 186109, 186110, 186111, 186112, 186201, 186202, 186203, 186204, 186205, 186206, 186207, 186208, 186209, 186210, 186211, 186212, 186301, 186302, 186303, 186304, 186305, 186306, 186307, 186308, 186309, 186310, 186311, 186312, 186401, 186402, 186403, 186404, 186405, 186406, 186407, 186408, 186409, 186410, 186411, 186412, 186501, 186502, 186503, 186504, 186505, 186506, 186507, 186508, 186509, 186510, 186511, 186512, 186601, 186602, 186603, 186604, 186605, 186606, 186607, 186608, 186609, 186610, 186611, 186612, 186701, 186702, 186703, 186704, 186705, 186706, 186707, 186708, 186709, 186710, 186711, 186712, 186801, 186802, 186803, 186804, 186805, 186806, 186807, 186808, 186809, 186810, 186811, 186812, 186901, 186902, 186903, 186904, 186905, 186906, 186907, 186908, 186909, 186910, 186911, 186912, 187001, 187002, 187003, 187004, 187005, 187006, 187007, 187008, 187009, 187010, 187011, 187012, 187101, 187102, 187103, 187104, 187105, 187106, 187107, 187108, 187109, 187110, 187111, 187112, 187201, 187202, 187203, 187204, 187205, 187206, 187207, 187208, 187209, 187210, 187211, 187212, 187301, 187302, 187303, 187304, 187305, 187306, 187307, 187308, 187309, 187310, 187311, 187312, 187401, 187402, 187403, 187404, 187405, 187406, 187407, 187408, 187409, 187410, 187411, 187412, 187501, 187502, 187503, 187504, 187505, 187506, 187507, 187508, 187509, 187510, 187511, 187512, 187601, 187602, 187603, 187604, 187605, 187606, 187607, 187608, 187609, 187610, 187611, 187612, 187701, 187702, 187703, 187704, 187705, 187706, 187707, 187708, 187709, 187710, 187711, 187712, 187801, 187802, 187803, 187804, 187805, 187806, 187807, 187808, 187809, 187810, 187811, 187812, 187901, 187902, 187903, 187904, 187905, 187906, 187907, 187908, 187909, 187910, 187911, 187912, 188001, 188002, 188003, 188004, 188005, 188006, 188007, 188008, 188009, 188010, 188011, 188012, 188101, 188102, 188103, 188104, 188105, 188106, 188107, 188108, 188109, 188110, 188111, 188112, 188201, 188202, 188203, 188204, 188205, 188206, 188207, 188208, 188209, 188210, 188211, 188212, 188301, 188302, 188303, 188304, 188305, 188306, 188307, 188308, 188309, 188310, 188311, 188312, 188401, 188402, 188403, 188404, 188405, 188406, 188407, 188408, 188409, 188410, 188411, 188412, 188501, 188502, 188503, 188504, 188505, 188506, 188507, 188508, 188509, 188510, 188511, 188512, 188601, 188602, 188603, 188604, 188605, 188606, 188607, 188608, 188609, 188610, 188611, 188612, 188701, 188702, 188703, 188704, 188705, 188706, 188707, 188708, 188709, 188710, 188711, 188712, 188801, 188802, 188803, 188804, 188805, 188806, 188807, 188808, 188809, 188810, 188811, 188812, 188901, 188902, 188903, 188904, 188905, 188906, 188907, 188908, 188909, 188910, 188911, 188912, 189001, 189002, 189003, 189004, 189005, 189006, 189007, 189008, 189009, 189010, 189011, 189012/)</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3">;Index</div>
<div class="ContentPasted3">y = (/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, -3, -3, -3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0.05, 0, 0, 0, 0, 1, 0.05, 0.05, 0.05, 0.05, 0.05, 2, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -2, -2, 0, 0, 0, 0, 0, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0.05, 1, 0.05, 0.05, 0.05, 0, 0, 0, 0, 0, 0, -1, -1, 0.05, 0.05, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0, 0, 0, 0, 0, 0, 0, -2, -3, -3, -3, -2, 0, 0, 0, 0, 0, 0.05, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/)</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> res@tmXBMode = "Manual" </div>
<div class="ContentPasted3"> res@tmXBTickStartF = 185501</div>
<div class="ContentPasted3"> res@tmXBTickEndF = 189012</div>
<div class="ContentPasted3"> ;res@tmXBTickSpacingF= 120</div>
<div class="ContentPasted3"> res@tmXBLabelStride = 1</div>
<div><br class="ContentPasted3">
</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> bc = new(432,string)</div>
<div class="ContentPasted3"> bc= "black"</div>
<div class="ContentPasted3">time = (/185501,185502,185503, 185504, 185505, 185506, 185507, 185508, 185509, 185510, 185511, 185512, 185601, 185602, 185603, 185604, 185605, 185606, 185607, 185608, 185609, 185610, 185611, 185612, 185701, 185702, 185703, 185704, 185705, 185706, 185707, 185708, 185709, 185710, 185711, 185712, 185801, 185802, 185803, 185804, 185805, 185806, 185807, 185808, 185809, 185810, 185811, 185812, 185901, 185902, 185903, 185904, 185905, 185906, 185907, 185908, 185909, 185910, 185911, 185912, 186001, 186002, 186003, 186004, 186005, 186006, 186007, 186008, 186009, 186010, 186011, 186012, 186101, 186102, 186103, 186104, 186105, 186106, 186107, 186108, 186109, 186110, 186111, 186112, 186201, 186202, 186203, 186204, 186205, 186206, 186207, 186208, 186209, 186210, 186211, 186212, 186301, 186302, 186303, 186304, 186305, 186306, 186307, 186308, 186309, 186310, 186311, 186312, 186401, 186402, 186403, 186404, 186405, 186406, 186407, 186408, 186409, 186410, 186411, 186412, 186501, 186502, 186503, 186504, 186505, 186506, 186507, 186508, 186509, 186510, 186511, 186512, 186601, 186602, 186603, 186604, 186605, 186606, 186607, 186608, 186609, 186610, 186611, 186612, 186701, 186702, 186703, 186704, 186705, 186706, 186707, 186708, 186709, 186710, 186711, 186712, 186801, 186802, 186803, 186804, 186805, 186806, 186807, 186808, 186809, 186810, 186811, 186812, 186901, 186902, 186903, 186904, 186905, 186906, 186907, 186908, 186909, 186910, 186911, 186912, 187001, 187002, 187003, 187004, 187005, 187006, 187007, 187008, 187009, 187010, 187011, 187012, 187101, 187102, 187103, 187104, 187105, 187106, 187107, 187108, 187109, 187110, 187111, 187112, 187201, 187202, 187203, 187204, 187205, 187206, 187207, 187208, 187209, 187210, 187211, 187212, 187301, 187302, 187303, 187304, 187305, 187306, 187307, 187308, 187309, 187310, 187311, 187312, 187401, 187402, 187403, 187404, 187405, 187406, 187407, 187408, 187409, 187410, 187411, 187412, 187501, 187502, 187503, 187504, 187505, 187506, 187507, 187508, 187509, 187510, 187511, 187512, 187601, 187602, 187603, 187604, 187605, 187606, 187607, 187608, 187609, 187610, 187611, 187612, 187701, 187702, 187703, 187704, 187705, 187706, 187707, 187708, 187709, 187710, 187711, 187712, 187801, 187802, 187803, 187804, 187805, 187806, 187807, 187808, 187809, 187810, 187811, 187812, 187901, 187902, 187903, 187904, 187905, 187906, 187907, 187908, 187909, 187910, 187911, 187912, 188001, 188002, 188003, 188004, 188005, 188006, 188007, 188008, 188009, 188010, 188011, 188012, 188101, 188102, 188103, 188104, 188105, 188106, 188107, 188108, 188109, 188110, 188111, 188112, 188201, 188202, 188203, 188204, 188205, 188206, 188207, 188208, 188209, 188210, 188211, 188212, 188301, 188302, 188303, 188304, 188305, 188306, 188307, 188308, 188309, 188310, 188311, 188312, 188401, 188402, 188403, 188404, 188405, 188406, 188407, 188408, 188409, 188410, 188411, 188412, 188501, 188502, 188503, 188504, 188505, 188506, 188507, 188508, 188509, 188510, 188511, 188512, 188601, 188602, 188603, 188604, 188605, 188606, 188607, 188608, 188609, 188610, 188611, 188612, 188701, 188702, 188703, 188704, 188705, 188706, 188707, 188708, 188709, 188710, 188711, 188712, 188801, 188802, 188803, 188804, 188805, 188806, 188807, 188808, 188809, 188810, 188811, 188812, 188901, 188902, 188903, 188904, 188905, 188906, 188907, 188908, 188909, 188910, 188911, 188912, 189001, 189002, 189003, 189004, 189005, 189006, 189007, 189008, 189009, 189010, 189011, 189012/)</div>
<div class="ContentPasted3"><br>
</div>
<div class="ContentPasted3">selyr = (/185709,185812,185912,186001, 186002,18603,186012, 187105,187211,187412,187506,187601,188001,188102,188204/)
</div>
<div class="ContentPasted3">do gg = 0,dimsizes(selyr)-1</div>
<div class="ContentPasted3"> bc = where(time.eq.selyr(gg),"grey",bc) </div>
<div class="ContentPasted3"> end do</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> res@gsnXYBarChartColors = "bc" </div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> </div>
<div class="ContentPasted3">plot=gsn_csm_xy(wks,x,y,res)</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3"> draw(plot)</div>
<div class="ContentPasted3"> frame(wks)</div>
<div><br class="ContentPasted3">
</div>
<div class="ContentPasted3">end</div>
<div><br class="ContentPasted3">
</div>
<div><br class="ContentPasted3">
</div>
<div><br class="ContentPasted3">
</div>
<br class="ContentPasted0">
</div>
<div><br class="ContentPasted0">
</div>
<br>
</div>
<div class="elementToProof">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Tahoma; font-size:13px"></div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">Dr. Melissa Lazenby
<div>Lecturer in Climate Change</div>
<div>Department of Geography</div>
<div>Chichester 1 C150</div>
<div>University of Sussex</div>
<div><br>
</div>
<div><i style="font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;">"Education is the most powerful weapon which you can use to change the world" Nelson Mandela</i><br>
</div>
<div><i style="font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;"><br>
</i></div>
<div><i style="font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;"><img style="max-width:100%" data-outlook-trace="F:1|T:1" src="cid:72ad72ef-975a-4887-a128-63e5bd225f2b"><br>
</i></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>