Re: problem with ContourPlot of discrete values (ExplicitLevels)

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 16 2012 - 10:23:41 MDT

Hi Chris,
Setting "BoxCenters" requires that you have one more label (set via
lbLabelStrings) and one more color (set via cnFillColors) than you do
contours (in your case set via cnLevels).

For example, let's say you only have 5 types of categorical data:
111,112,300,511,and 512. You would want to set up your resources to
something like this:
res_clc@cnLevels = (/112,300,511,512/) ; 4 contours
res_clc@cnFillColors = (/"green", "purple", "brown", "SlateBlue",
"orangered"/) ; 5 colors
res_clc@lbLabelAlignment = "BoxCenters"
res_clc@lbLabelStrings = //
<http://www.ncl.ucar.edu/Document/Graphics/Resources/lb.shtml#lbLabelStrings>(/111,112,300,511,512/)
; 5 labels

Those settings will result in all values less than 112.0 to be colored
green (=all of your 111 value areas), all values between 112 and 299.999
to be colored purple, and so on. So, I think you need to simply change
this line:
res_clc@cnLevels = clc_classes
to this:
res_clc@cnLevels = clc_classes(1:)

See examples #4 and #14 here if you want some other examples of this method:
http://www.ncl.ucar.edu/Applications/labelbar.shtml#ex4

Hope that all makes sense.. If not, let ncl-talk know..
Good luck,
Adam

On 08/16/2012 05:50 AM, Christopher Danek wrote:
> Hi all,
>
> I have a plot problem concerning the ContourPlot Resources
> 'cnLevelSelectionMode'.
> As you can see in the picutere (screenshot of wks_type = "ps"), I want
> to have a contour plot of landuse data (integers). The problem is that
> somehow a 30th value called 'Label_29' colored dark-grey is added to
> the labelbar of the contourplot. That does not happen at the
> histogram-plot but though this additional value, the data become
> shifted one position, wherefore the histogram does not fit to the
> contourplot.
> These are the resources for the contourplot:
>
> res_clc@cnFillOn = True ; turn
> on color
> res_clc@cnFillMode = "RasterFill" ; much
> faster to plot high res data
> res_clc@cnLinesOn = False ; no
> contour lines
> res_clc@cnLineLabelsOn = False ; no line
> labels
> res_clc@tmXBLabelStride = 1
> res_clc@lbLabelAlignment = "BoxCenters"
> res_clc@lbLabelStrings = clc_classes
> res_clc@lbLabelAngleF = 65
> res_clc@lbLabelFontHeightF = 0.015
> res_clc@cnLevelSelectionMode = "ExplicitLevels" ; set manual
> contour levels
> res_clc@cnLevels = clc_classes
> res_clc@cnFillColors = clc_colors
>
> with
>
> clc_classes =
> (/111,112,121,122,123,124,131,132,133,141,142,211,221,222,231,242,243,311,312,313,321,322,324,331,411,412,423,511,512/)
> ; n = 29
> clc_colors = (/"green", "purple", "brown", "SlateBlue", "orangered",
> "blue", "palevioletred", "olivedrab2", \
> "wheat", "OliveDrab","darkgreen", "skyblue2", "yellow",
> "red", "green", \
> "HotPink", "brown", "Blue", "LightGrey",
> "MediumTurquoise", "purple" , \
> "DarkSeaGreen", "Peru", "Tomato", "blue", "green",
> "orange", "orchid", "red"/) ; n = 29
>
> and
>
> plot(0) = gsn_csm_contour(wks,data_clc(::-1,:),res_clc) ; 2d
> plot(1) = gsn_histogram(wks,data_1d_clc,res_clc_hist) ; same data
> with ndtooned() for this resource I use:
> res_clc_hist@gsnHistogramDiscreteBinValues = clc_classes and
> res_clc_hist@gsFillColor = clc_colors
>
>
> I found out that 'Label_29' only appears when I use "BoxCenters" as
> lblabelAlignment. If I use the default value for this resource, a 30th
> color apperas but without the label 'Label_29'
>
> Does anyone know how to fix this problem of plotting increasing values
> with irregular gaps like 'clc_classes' ?
> Thanks for any advice
> Wish you a nice summer,
> Chris
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 16 10:23:50 2012

This archive was generated by hypermail 2.1.8 : Thu Aug 23 2012 - 16:16:15 MDT