<div dir="ltr">Hi Melissa,<div>It looks to me like you are close. The range of XBValues needs to match the range X-axis inputs in the gsn_csm_xy call. It looks like </div><div>you have tried different permutations of this. For simplicity of the x-axis labels I would go with the 1856-1889 values. </div><div><br></div><div>I also believe that it would be best to set the trXMinF/trXMaxF resources so that each set of bars is overlaid on the exact same </div><div>plot window with the same min/max values, otherwise NCL will automatically set these resources. I think this is why your bars are </div><div>being set on top of one another.</div><div><br></div><div>So I'd give this a try:</div><div>sres@trXMinF = 1855</div><div>sres@trXMaxF = 1890</div>sres@tmXBValues = ispan(1855,1890,5) ; create major tickmarks with labels every 5 years<br><div>sres@tmXBLabels = sres@tmXBValues<br></div><div>sres@tmXBMinorValues = ispan(1855,1890,1). ; as tmXBMode = "Explicit", this resource needs to be set to get minor tickmarks. Create minor tickmarks every year.</div><div><snip></div><div> sres@gsnXYBarChartColors = (/"red"/) <br> plot1 = gsn_csm_xy(wks,fspan(1855.7,1888.7,34),stdarr(:,0),sres) ; draw each time series<br> sres@gsnXYBarChartColors = (/"lightblue"/) ; seperately, not<br> plot2 = gsn_csm_xy(wks,fspan(1855.9,1888.9,34),stdarr(:,1),sres) ; advancing the frame<br> sres@gsnXYBarChartColors = (/"blue"/) ; but tweaking where<br> plot3 = gsn_csm_xy(wks,fspan(1856.1,1889.1,34),stdarr(:,2),sres) ; each time series is<br> sres@gsnXYBarChartColors = (/"green"/) ; drawn on the X-axis<br> plot4 = gsn_csm_xy(wks,fspan(1856.2,1889.2,34),stdarr(:,3),sres)<br></div><div><br></div><div>I tweaked the fspan settings above to sit within the range of tmXBValues, and to reflect that you set sres@gsnXYBarChartBarWidth=.2. For instance, the first bar in </div><div>plot1 should run from 1855.6-1855.8, the first bar in plot2 should run from 1855.8-1856, and so on so that they are all grouped together for each timestep. </div><div><br></div><div>You might have to tweak some other settings, but this should get you started at the very least.<br></div><div>Good luck!</div><div>Adam</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 3, 2023 at 5:14 AM Melissa Lazenby via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div dir="ltr">
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Dear All NCL Users</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br>
</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">I hope you are well. </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">I am trying to make a bar plot that has 4 bars per year in a times series from 1856-1889. </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">I have managed to make a plot however the bars are overlaying on one another, and I would
like them side by side like the example unique_5. </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">I have used the fspan option like the example for unique 5 does but it does not seem to
be working. </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">I also am having issues with my x axis labels being the years. </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Any help to rectify this issue would be greatly appreciated. Below are the output of the
figure and code.</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br>
</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Many thanks!</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br>
</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Kindest Regards</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Melissa</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br>
</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><img style="max-width: 100%;" size="35799" src="cid:186182dc52fcb971f161"><br>
</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">;*******************************************************
<div>; Mpwapwa_unique_5.ncl</div>
<div>;</div>
<div>; Concepts illustrated:</div>
<div>; - Drawing multiple bar charts on a page</div>
<div>; - Drawing three custom legends outside a bar chart</div>
<div>; - Using bar charts to draw standard deviations for four time series</div>
<div>; - Drawing a time series plot</div>
<div>;*******************************************************</div>
<div>;</div>
<div>; These files are loaded by default in NCL V6.2.0 and newer</div>
<div>; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div>
<div>; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div>
<div><br>
</div>
<div>begin</div>
<div> </div>
<div><br>
</div>
<div>x = (/1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889/)</div>
<div><br>
</div>
<div>yIndex = (/0,2,-1,-3,2,0,0,0,0,0,0,0,0,0,0,0,2,0,-1,-1,-2,1,1,-2,-2,1,-1,-3,0,0,0,-3,0,0/)</div>
<div><br>
</div>
<div>y20CR3 = (/-1.7049024, -1.9956352, 0.1017878, 1.5787968, 0.2902762, 0.1615032, 0.7573914, 0.127654184, 0.3391526, 0.18975348, 1.4533978, 0.28738338, 0.8228474, -1.2142216, 0.67589808, 1.3983746, 1.1087944, 0.58095216, -1.3422622, 0.226781852, 2.173188, 0.6511904, 0.9723054, -0.4989326, -1.5402072, -0.1535788, -0.226605, -1.6808838, -0.19809544, -0.1772666, 0.0769234, -0.6346154, -1.2222682, -0.0073483/)</div>
<div><br>
</div>
<div><br>
</div>
<div>;scaled by 10</div>
<div>yLMR = (/0.54, -0.0624672, -0.0590976, 0.322272, -1.14912, 0.863136, 0.7776, 1.2528, -0.0831168, 1.19232, 0.03024, 0.507168, 0.96768, 0.63504, 1.43424, 1.79712, 0.555552, 0.478656, 1.0368, 0.679104, 0.1944, 0.292896, 0.9936, 1.08, 1.18368, 1.26144, 0.631584, -0.627264, -0.97632, -0.325728, 0.00860544, -0.800928, -0.0360288, 0.186624/)</div>
<div><br>
</div>
<div><br>
</div>
<div>;scaled by 5</div>
<div>yCMIP5 = (/-0.9094243, 0.5458735, -0.8682191, -1.826278, -0.6501346, 0.1305088, 0.51643, 0.6247665, -0.4082086, 0.3641764, 1.476322, 0.842743, -0.5013026, -0.1281874, 0.4829363, -0.7015711, 0.269588, -0.2834916, -0.8827865, -0.4242322,
-1.171241, -0.8289737, -0.4638377, 0.8812776, 0.5154026, -1.191759 ,0.8223722, -1.198702, -0.8878552, -1.724694, -1.62958, 1.02131, -1.440305, -2.299565/)</div>
<div><br>
</div>
<div>;yCMIP5 = (/-1.329231, -0.9094243, 0.5458735, -0.8682191, -1.826278, -0.6501346, 0.1305088, 0.51643, 0.6247665, -0.4082086, 0.3641764, 1.476322, 0.842743, -0.5013026, -0.1281874, 0.4829363, -0.7015711, 0.269588, -0.2834916, -0.8827865,
-0.4242322, -1.171241, -0.8289737, -0.4638377, 0.8812776, 0.5154026, -1.191759 ,0.8223722, -1.198702, -0.8878552, -1.724694, -1.62958, 1.02131, -1.440305, -2.299565/)</div>
<div><br>
</div>
<div><br>
</div>
<div> stdarr = new((/34,4/),"float")</div>
<div> do hh = 0,33</div>
<div> stdarr(hh,0) = (/ (yIndex(hh::34)) /)</div>
<div> stdarr(hh,1) = (/ (y20CR3(hh::34)) /)</div>
<div> stdarr(hh,2) = (/ (yLMR(hh::34)) /)</div>
<div> stdarr(hh,3) = (/ (yCMIP5(hh::34)) /)</div>
<div> end do</div>
<div> print("Index Data = "+dimsizes(yIndex)+", 20CR3 = "+dimsizes(y20CR3)+", LMR = "+dimsizes(yLMR)+", CMIP5 = "+dimsizes(yCMIP5))</div>
<div><br>
</div>
<div>;====================================================================================== </div>
<div> wks = gsn_open_wks("X11","Mpwapwa_4_Plot") ; send graphics to PNG file</div>
<div><br>
</div>
<div> sres = True</div>
<div> sres@vpWidthF = 0.7</div>
<div> sres@vpHeightF = 0.5</div>
<div> sres@vpXF = .15</div>
<div> sres@trYMinF = -3.5</div>
<div> sres@trYMaxF = 3.5</div>
<div> sres@gsnDraw = True</div>
<div> sres@gsnFrame = False</div>
<div> sres@gsnXYBarChart = True</div>
<div> sres@gsnXYBarChartBarWidth = 0.20 ; change bar widths</div>
<div> sres@tmXBMode = "Explicit" ; explicit labels</div>
<div> sres@tmXBValues = (/1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889/)</div>
<div> ;sres@tmXBValues = (/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34/)</div>
<div> sres@tmXBLabels = (/"1856","1857","1858", "1859", "1860", "1861", "1862", "1863", "1864", "1865", "1866", "1867", "1868", "1869", "1870", "1871", "1872", "1873", "1874", "1875", "1876", "1877", "1878", "1879", "1880", "1881", "1882", "1883", "1884", "1885", "1886", "1887", "1888", "1889"/)</div>
<div> sres@tmXBLabelFontHeightF = 0.0205</div>
<div> sres@tmXTLabelFontHeightF = 0.0205</div>
<div> sres@tmYLLabelFontHeightF = 0.0225</div>
<div> sres@tiMainFontHeightF = 0.025</div>
<div> sres@tiMainFont = "helvetica"</div>
<div> sres@tiMainString = "Precipitation Anomalies for all 4 datasets"</div>
<div> sres@gsnRightString = ""</div>
<div> sres@tiYAxisString = "Pr Anomalies (mm/day)"</div>
<div> sres@gsnYRefLine = 0. ; reference line </div>
<div> </div>
<div> sres@gsnXYBarChartColors = (/"red"/) </div>
<div> plot1 = gsn_csm_xy(wks,fspan(.775,33.775,34),stdarr(:,0),sres) ; draw each time series</div>
<div> sres@gsnXYBarChartColors = (/"lightblue"/) ; seperately, not</div>
<div> plot2 = gsn_csm_xy(wks,fspan(.925,33.925,34),stdarr(:,1),sres) ; advancing the frame</div>
<div> sres@gsnXYBarChartColors = (/"blue"/) ; but tweaking where</div>
<div> plot3 = gsn_csm_xy(wks,fspan(1.075,34.075,34),stdarr(:,2),sres) ; each time series is</div>
<div> sres@gsnXYBarChartColors = (/"green"/) ; drawn on the X-axis</div>
<div> plot4 = gsn_csm_xy(wks,fspan(1.225,34.225,34),stdarr(:,3),sres)</div>
<div><br>
</div>
<div> lbres = True ; labelbar only resources</div>
<div> lbres@vpWidthF = 0.2 ; labelbar width</div>
<div> lbres@vpHeightF = 0.1 ; labelbar height</div>
<div> lbres@lbBoxMajorExtentF = 0.36 ; puts space between color boxes</div>
<div> lbres@lbFillColors = (/"green","blue"/)</div>
<div> lbres@lbMonoFillPattern = True ; Solid fill pattern</div>
<div> lbres@lbLabelFontHeightF = 0.025 ; font height. default is small</div>
<div> lbres@lbLabelJust = "CenterLeft" ; left justify labels</div>
<div> lbres@lbPerimOn = False</div>
<div> lbres@lgPerimColor = "white"</div>
<div> labels = (/"CMIP5","20CR3"/)</div>
<div> gsn_labelbar_ndc(wks,2,labels,0.52,0.23,lbres) ; draw right labelbar column</div>
<div> </div>
<div> lbres@lbFillColors = (/"lightblue","red"/)</div>
<div> labels = (/"LMR","Index"/)</div>
<div> gsn_labelbar_ndc(wks,2,labels,0.17,0.23,lbres) ; draw left labelbar column</div>
<div> frame(wks) </div>
<div>end</div>
<br>
</span></div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="m_9065648695579107392m_-5550379284261410363m_-1859586910364916589Signature">
<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="color:inherit;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="color:inherit;font-family:inherit;font-size:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit"><br>
</i></div>
<div><i style="color:inherit;font-family:inherit;font-size:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit"><img style="max-width: 100%;" src="cid:186182dc52f8943e5402"><br>
</i></div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist IV, Climate Analysis Section</font></span></div><div><span><font color="#888888">Climate and Global Dynamics Laboratory<br></font></span></div></div><div><span style="color:rgb(136,136,136)">National Center for Atmospheric Research</span><span><font color="#888888"><br></font></span></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>