<div dir="ltr">Hi SBR,<div>First, welcome to NCL! As you are a new user we strongly recommend that you read through the NCL User Guide and the Mini-Language manual, both linked from here:</div><div><a href="http://www.ncl.ucar.edu/Document/Manuals/" target="_blank">http://www.ncl.ucar.edu/<wbr>Document/Manuals/</a><br></div><div><br></div><div>With regards to your question:</div><div><span style="font-size:12.8px">"I want to keep the Y axis as it is but want to change the X axis to</span><br style="font-size:12.8px"><span style="font-size:12.8px">Period with scale 4 8 16 32 64 128 256 512."</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I think you need to set the following:</span></div><div><div><span style="font-size:12.8px">r@xyXStyle = "Irregular"</span></div><div><span style="font-size:12.8px">r@xyXIrregularPoints = (/.01,.1,.2,.25,.5/) </span></div></div><div><span style="font-size:12.8px">Note that the setting of xyXIrregularPoints in purely subjective. The spacing between each value on the X-axis will be the same regardless of the size of the value, so set this however you want.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">If you want the labels of the X-axis to be </span><span style="font-size:12.8px">4 8 16 32 64 128 256 512, then you need to set the tmXBValues and tmXBLabels resources as I suggested in my initial reply. Note that to set these resources the formula to use is:</span></div><div><span style="font-size:12.8px">1/frequency = period, or 1/tmXBValues = tmXBLabels. As an example, for the returned spectra the smallest period will be 2 years, and the frequency is .5. (1/.5 = 2)</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Here would be the settings for your first 4 labels; I leave the rest for you to calculate.</span></div><div><span style="font-size:12.8px">r@tmXBValues = (/.03125,.0625,.125,.25</span><span style="font-size:12.8px">/)</span><br style="font-size:12.8px"><span style="font-size:12.8px">r@tmXBLabels = (/"32","16","8","4"/)</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">If you want the periods (frequency) to increase (decrease) along the x-axis as opposed to decreasing (increasing), you can set r@trXReverse = True</span></div><div><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Document/Graphics/Resources/tr.shtml#trXReverse">http://www.ncl.ucar.edu/Document/Graphics/Resources/tr.shtml#trXReverse</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Finally, colleague sent in an example spectra script that sets various options and walks one through an alternative way to create a spectra plot with the period as the x-axis. I have attached it here.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Hope that helps. If you have any further questions please reply to the ncl-talk email list.</span></div><div><span style="font-size:12.8px">Adam</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 16, 2017 at 7:51 PM, S. B. Ratna <span dir="ltr"><<a href="mailto:sbratna2012@gmail.com" target="_blank">sbratna2012@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Adam,<br>
Thanks for your reply. I am a new user of NCL and difficult to<br>
understand many things now.<br>
I am trying to modify the following code as per your instructions.<br>
<a href="https://www.ncl.ucar.edu/Applications/Scripts/spec_4.ncl" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/<wbr>Applications/Scripts/spec_4.<wbr>ncl</a><br>
<br>
I want to keep the Y axis as it is but want to change the X axis to<br>
Period with scale 4 8 16 32 64 128 256 512.<br>
Could you please suggest how to change this part of the code.<br>
<br>
;*****************************<wbr>*******************<br>
; plotting<br>
;*****************************<wbr>*******************<br>
wks = gsn_open_wks("ps","spec") ; Opens a ps file<br>
<br>
r = True ; plot mods desired<br>
r@tiMainString = "SOI" ; title<br>
r@tiXAxisString = "Frequency (cycles/month)" ; xaxis<br>
r@tiYAxisString = "Variance" ; yaxis<br>
;*****************************<wbr>******************<br>
; Generate log plot showing "red noise" confidence bounds<br>
; (a) log scaling and (b) the Band Width<br>
;*****************************<wbr>******************<br>
r@trYLog = True ; log scaling<br>
r@trYMinF = 0.10 ; manually set lower limit<br>
r@trYMaxF = 30.0 ; " upper<br>
r@gsnFrame = False ; do not advance frame<br>
plot = gsn_csm_xy(wks,sdof@frq, splt,r)<br>
<br>
xf = (/0.40, 0.40+sdof@bw/) ; Create band width line<br>
ys = 0.75*max(sdof@spcx) ; 75% up Y axis<br>
yv = (/ys,ys/)<br>
rpl = True ; resources for polyline<br>
rpl@gsLineThicknessF = 2 ; Define line thickness<br>
gsn_polyline(wks,plot,xf,yv,<wbr>rpl) ; Draw BandWidth<br>
<br>
txres= True ; label BW line<br>
txres@txFontHeightF = 0.015 ; font height<br>
txres@txJust = "CenterLeft" ; Set lable location<br>
gsn_text(wks,plot,"BW",0.41+<wbr>sdof@bw,ys,txres); Label<br>
frame (wks)<br>
end<br>
<br>
Thanks.<br>
SBR<br>
<br>
On Fri, Jun 16, 2017 at 10:57 PM, Adam Phillips <<a href="mailto:asphilli@ucar.edu">asphilli@ucar.edu</a>> wrote:<br>
> Hi SBR,<br>
> To switch to period being on the bottom y-axis you can do something like<br>
> this:<br>
> pres@tmXBMode = "Explicit"<br>
> pres@tmXBValues = (/".02",".10",".20",".3333",".<wbr>50"/)<br>
> pres@tmXBLabels = (/"50","10","5","3","2"/)<br>
> pres@tiXAxisString = "Period (years)"<br>
><br>
> To alter the Y-axis type, you can set trYAxisType and trYCoordPoints as is<br>
> done in XY example #30 here:<br>
> <a href="http://www.ncl.ucar.edu/Applications/xy.shtml#ex30" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/xy.shtml#ex30</a><br>
><br>
> Hope that helps. If you have any further questions please respond to the<br>
> ncl-talk email list.<br>
> Adam<br>
><br>
><br>
><br>
><br>
><br>
> On Fri, Jun 16, 2017 at 12:52 PM, S. B. Ratna <<a href="mailto:sbratna2012@gmail.com">sbratna2012@gmail.com</a>> wrote:<br>
>><br>
>> Hi All,<br>
>> I would like to plot the spectral analysis for my annual mean data for<br>
>> about 800 years. I would like to use 'spec_4.ncl' but I need "period<br>
>> (year)" in the X-axis instead of "Frequency".<br>
>> Also, the X-axis scale should be 4 8 16 32 64 128 256 512.<br>
>> Could you please suggest how to draw such figure.<br>
>> <a href="https://www.ncl.ucar.edu/Applications/Scripts/spec_4.ncl" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/<wbr>Applications/Scripts/spec_4.<wbr>ncl</a><br>
>><br>
>> Thanks.<br>
>> SBR<br>
>> ______________________________<wbr>_________________<br>
>> ncl-talk mailing list<br>
>> <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> List instructions, subscriber options, unsubscribe:<br>
>> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
><br>
><br>
><br>
<span class="HOEnZb"><font color="#888888">><br>
> --<br>
> Adam Phillips<br>
> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR<br>
> <a href="http://www.cgd.ucar.edu/staff/asphilli/" rel="noreferrer" target="_blank">www.cgd.ucar.edu/staff/<wbr>asphilli/</a> <a href="tel:303-497-1726" value="+13034971726">303-497-1726</a><br>
><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><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, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></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><span><font color="#888888">303-497-1726 </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>
</div>