Set Colormap for a contour plot or any plot that supports a colormap
int dataplot_set_colormap( DataPlot & dp, const vector<double> & vZLevels, const vector<uint> & vnFillColors, uint ncAbove = SYSCOLOR_GRAY, uint ncBelow = SYSCOLOR_BLACK, int nModifyContourLines = -1, int nLogScale = -1, const vector<uint> & vnLineColors = NULL, const vector<uint> & vnLineStyles = NULL, const vector<double> & vLineThickness = NULL )
return 0 for success, otherwise return -1 if dp invalid, or -3 if dp does not support colormap, or -2 if vzLevels and vnColors are not proper size, or -4 if SetColormap call failed for unknown reasons.
EX1
// set fill color with Z range levels //For this example to run, an active graph layer with at least one dataplot must exist in the project void dataplot_set_colormap_ex1() { GraphLayer gl = Project.ActiveLayer(); DataPlot dp = gl.DataPlots(0); if(dp) { vector vLevels = {-3, 0, 3}; vector<uint> vnColors = {SYSCOLOR_GREEN, SYSCOLOR_BLUE}; if( 0 != dataplot_set_colormap(dp, vLevels, vnColors) ) out_str("Fail to set colormap"); } }
EX2
// set fill color and lines with Z range levels //For this example to run, an active graph layer with at least one dataplot must exist in the project void dataplot_set_colormap_ex2() { GraphLayer gl = Project.ActiveLayer(); DataPlot dp = gl.DataPlots(0); if(!dp) return; vector vLevels; BOOL bLogScale = false; dp.GetColormap(vLevels, bLogScale); // change the number of Z levels to 5 double dMin = vLevels[0]; double dMax = vLevels[vLevels.GetSize()-1]; int nNewSteps = 5; vLevels.Data(dMin, dMax, (dMax - dMin)/(nNewSteps-1)); vector<uint> vnFillColors = {SYSCOLOR_GREEN, SYSCOLOR_BLUE, SYSCOLOR_CYAN, SYSCOLOR_MAGENTA}; vector<uint> vnLineColors = {SYSCOLOR_YELLOW, SYSCOLOR_DKYELLOW, SYSCOLOR_NAVY, SYSCOLOR_PURPLE}; // line styles vector<uint> vnStyles(vnLineColors.GetSize()); vnStyles = 2; // Dot // line thickness vector vThickness(vnLineColors.GetSize()); vThickness = 2.0; if( 0 != dataplot_set_colormap(dp, vLevels, vnFillColors, SYSCOLOR_GRAY, SYSCOLOR_BLACK, -1, -1, vnLineColors, vnStyles, vThickness) ) out_str("Fail to setup colormap"); }
origin.h