Re: Histogram questions - transparent fill? bar distance?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue, 20 Jan 2009 09:05:13 -0700 (MST)

On Sun, 18 Jan 2009, Michel dos Santos Mesquita wrote:

> Hi everyone,
> I am creating two histograms plotted in the same figure in NCL (using two
> dataset values per bin in the histogram) - like this NCL example:
> I have two questions about that:
> 1) Is there a way for me to change the distance between the two column
> bars (in each bin)? - that is, instead of plotting one behind the other, I
> would like to plot them one next to the other.

Hi Michel,

The histogram plots have very limited capability, and there's no way
to do this with two plots that are being compared. However, see
my answer to #2.

> 2) I have attached a figure which was created in another program. I would
> like to reproduce that figure in NCL. Two histograms shown in the same
> plot: one in the background in gray color. The other in the foreground
> using transparent fill. Is that possible in NCL? How?

First, NCL cannot do transparent color, although this is something
we're working on.

To do the kind of plot you want, I would call gsn_histogram twice,
drawing each plot on the same page. To do this, you have to be
careful that both plots use the same bin intervals, and have the
same Y axis limits. Here's a sample script that should
run as is:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"

; Generate some random data.

   z1 = random_uniform(0,320.,500)
   z2 = random_uniform(0,320.,700)

; Open workstation
   wks = gsn_open_wks("x11","histo")

; Plot mods
   res = True
   res_at_gsnFrame = False ; Don't advance frame

   res_at_trYMinF = 0. ; Control limits for Y axis
   res_at_trYMaxF = 110.

   res_at_gsnHistogramBinIntervals = ispan(0,320,40) ; self explanatory

   res_at_gsnHistogramBarWidthPercent = 100. ; Bars will be touching
   res_at_gsFillColor = "gray"

   plot = gsn_histogram(wks,z1,res)

   res_at_gsFillColor = "transparent"

   plot = gsn_histogram(wks,z2,res)

   plot = gsn_histogram(wks,z2,res)


> I thank you in advance!
> Regards,
> Michel
> --
> Michel Mesquita
> PhD Student
> -----------------------------------------
> This email was sent using SquirrelMail.
> "Webmail for nuts!"
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Jan 20 2009 - 09:05:13 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 21 2009 - 13:09:21 MST