Re: Replace Frequency With Percent in Histogram

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 18 2010 - 14:25:18 MDT

Dan,

In answer to your second question, I was hoping it's as easy as
setting trYMaxF to the maximum value you plan to have, but I'm not so
sure. Let me see if I can create an example.

--Mary

On Mar 18, 2010, at 8:03 AM, Dan Barrie wrote:

> That worked perfectly, and having edited gsn_code.ncl for the first
> time, I'd like to thank you for how well-written and commented the
> code is.
>
> For anyone else who reads this thread in the future, I found it
> necessary to change two more things:
>
> 1. Get rid of the "Percent" label on the right Y-axis. This is
> accomplished by altering line 7764 of the code (gsn_code.ncl). I
> changed the line perc_String = "Percent" to perc_String = ""
> 2. To get rid of the tick marks on the right Y-axis, I added the
> following resource to my histogram script: res@tmYROn = False
>
> Mary, I have one more question about this histogram. The only
> remaining issue is that the left y-axis is being scaled to
> frequency values, not percentage values, which is a problem, since
> my data sets have different numbers of data points, and I am
> automating their handling as much as possible. For example, 40% in
> one data set might be 8000 points, but 40% in another data set
> might be 1000 points. I would like to keep the scaling constant, so
> is there a way to switch the scaling so that the left y-axis can be
> scaled by percentage? Thanks!
>
> -Dan
>
>
>
>
> Mary Haley wrote:
>>
>> Hi Dan,
>>
>> The histogram code only allows you to put these special labels on
>> the right.
>>
>> If you want to put them on the left, you will need to make a personal
>> copy of $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl and edit
>> it.
>>
>> Where you see the lines:
>>
>> set_attr(res2,"tmYUseLeft", False)
>> set_attr(res2,"tmYROn",True)
>> set_attr(res2,"tmYRLabelsOn",True)
>> set_attr(res2,"tmYRMode","Explicit")
>> set_attr(res2,"tmYRValues",bins_at_pnice)
>> set_attr(res2,"tmYRMinorValues",bins_at_pmnice)
>> if(percentsign)
>> set_attr(res2,"tmYRLabels",pnice+"%")
>> else
>> set_attr(res2,"tmYRLabels",pnice)
>> end if
>>
>>
>> You will want to change YR to YL.
>>
>> I haven't actually tested this, so let me know if it doesn't work.
>>
>> You will also need to do Dennis' suggestion below of setting
>> tiYAxisString to "Percent" or "%".
>>
>> --Mary
>>
>>
>> On Mar 17, 2010, at 9:28 AM, Dennis Shea wrote:
>>
>>> Try
>>>
>>> res@tiYAxisString = "Percent"
>>>
>>> On 03/17/2010 08:36 AM, Dan Barrie wrote:
>>>> Dear NCL users,
>>>>
>>>> I would like to replace the default histogram left Y-Axis values
>>>> for
>>>> "Frequency" with "Percent", which appears on the right Y-Axis by
>>>> default
>>>> when res@gsnHistogramComputePercentages is set to True. Does
>>>> anyone have
>>>> a suggestion for how to do this? Thanks.
>>>>
>>>> -Dan
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>> --
>>> ======================================================
>>> Dennis J. Shea tel: 303-497-1361 |
>>> P.O. Box 3000 fax: 303-497-1333 |
>>> Climate Analysis Section |
>>> Climate & Global Dynamics Div. |
>>> National Center for Atmospheric Research |
>>> Boulder, CO 80307 |
>>> USA email: shea 'at' ucar.edu |
>>> ======================================================
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 18 14:26:21 2010

This archive was generated by hypermail 2.1.8 : Fri Mar 19 2010 - 16:19:08 MDT