English

How To: Use the RampColors and RampSubset requests

Summary

The following script demonstrates how to color a 10 class legend with 0 - 5 as a Red to White ramp, and 5 - 10 as a White to Blue ramp.

Procedure


Code:

'-- multi_ramp_colors_legend.ave
'
'-- This script assumes that you have a theme with a
'-- NUMERIC field called "Sumblkpop" in View1.
'-- You should substitute your NUMERIC field name for fname.
'
theView=av.GetProject.FindDoc("View1")
theTheme = theView.GetActiveThemes.Get(0)
theFTab = theTheme.GetFTab
fname="Pop1991"
f = theFTab.FindField(fname)
theLegend = theTheme.GetLegend
theLegend.SetLegendType(#LEGEND_TYPE_COLOR)
'
'-- You will need to change the number of quantiles.
'-- This script sets it to 10.
'
theLegend.Quantile(theTheme,f.AsString,10)
thesymList = theLegend.getsymbols
'
'-- If you do not like the desired colors for the
'-- Begin and End of the RampColors you will have to
'-- specify one of the preset colors (ie. White, Green, Black, etc.
'-- or define your own color with the Make and SetRGBList
'-- commands. Note how the RampColors goes from Red to Blue;
'-- if you were to eliminate the 2 RampSubset
'-- requests below you would just get one color ramp.
'
theSymList.rampcolors(Color.GetRed, Color.GetBlue)
'
'-- You need to specify the a Middle color for the RampSubset.
'
theMiddleSym = theSymList.Get(4)
theMiddleSym.Setcolor(Color.GetWhite)
'
'-- The mini Ramps go from Red to White 'RampSubset(0,4)'
'-- and White to Blue 'RampSubset(4,9)'.
'-- Note: If you were to only specify one of the RampSubsets
'-- you would find that the rest of the RampColors request
'-- above (Red to Blue) would still be in effect for those
'-- symbols outside of the RampSubset.
'
thesymList.rampsubset(0,4)
thesymList.rampsubset(4,9)
theTheme.UpdateLegend
'
'-- End of multi_ramp_colors_legend.ave