2.2.4.8.39 DataPlot::SetModifier

Description

It sets a modifier, like to specify that a symbol size or color in a scatter plot, comes from another column.

Syntax

int SetModifier(int nDesig, Column &col)

Parameters

nDesig
[input]the property for which the modifier is specified:
COLDESIG_SIZE, symbol size
COLDESIG_COLOR, symbol color from a colormap
COLDESIG_VECTOR_ANGLE, vector plot angle column
COLDESIG_VECTOR_MAGNITUDE, vector plot magnitude column
COLDESIG_VECTOR_XEND, flow vector x-coordinate of the arrow end
COLDESIG_VECTOR_XEND, flow vector y-coordinate of the arrow end
COLDESIG_PLOTLABEL_FORM, label
see PlotDesignationEx in OC_const.h for more options.
col
[input]the column to be used as the modifier from which the dataplot will draw values for the modified property.

Return

Returns the previous modifier index, or 0 if previously the property was not a modifier value, or an error if the return value < -13000.

Examples

EX1

// have a worksheet active and import Samples\Graphing\group.dat into it.
void DataPlot_SetModifier_ex1()
{
	Worksheet		wks = Project.ActiveLayer();
	if( !wks )
	{
		out_str("Pls activate worksheet with group.dat data");
		return;
	}
	
	GraphPage		gp;
	gp.Create("bubble");
	
	GraphLayer		gl = Project.ActiveLayer();
	DataRange		dr;
	dr.Add(wks, 0, "X");
	dr.Add(wks, 1, "Y");
	int				nPlot = gl.AddPlot(dr, IDM_PLOT_SCATTER);
	DataPlot		dp = gl.DataPlots(0);
	Column			col = wks.Columns(1);
	dp.SetModifier(COLDESIG_SIZE, col);
	
	gl.Rescale(); 
}

EX2

// create an XY scatter plot with colormap from other columns
// have a worksheet that has at least three columns active before execution
void DataPlot_SetModifier_ex2()
{
	Worksheet wks = Project.ActiveLayer();
	DataRange dr;	
	dr.Add(wks, 0, "X");
	dr.Add(wks, 1, "Y");
	GraphPage gp;
	gp.Create("Origin");
	GraphLayer gl = gp.Layers();	
	gl.AddPlot(dr, IDM_PLOT_SCATTER);
        DataPlot dp = gl.DataPlots(0); 
	if( !dp )
		return;
	Column col(wks, 2);
	dp.SetModifier(COLDESIG_COLOR, col);
	gl.Rescale();
}

EX3

// assum a worksheet has 3 columns
// make a scatter plot with first 2 columns 
// and use the 3rd column as plot label
void DataPlot_SetModifier_ex3()
{
	Worksheet wks = Project.ActiveLayer();
	if(!wks)
		return;
	Column col(wks, 2);
	if(!col)
		return;
	
	DataRange dr;	
	dr.Add(wks, 0, "X");
	dr.Add(wks, 1, "Y");
	
	GraphPage gp;
	gp.Create("Origin");
	GraphLayer gl = gp.Layers();	
	gl.AddPlot(dr, IDM_PLOT_SCATTER);
	gl.Rescale();
	
	DataPlot dp = gl.DataPlots(0); 
	if(!dp)
		return;
	dp.SetModifier(COLDESIG_PLOTLABEL_FORM, col);
	
	vector<int> vnDesigs;
	vector<string> saNames;
	dp.GetModifiers(vnDesigs, saNames);
	
	vector<uint> vecIndex;
	if(vnDesigs.Find(vecIndex, COLDESIG_PLOTLABEL_FORM) > 0) 
	{
		printf("label form = %s\n", saNames[ vecIndex[0] ]);
	}
}

Remark

See Also

GraphLayer::AddPlot
DataPlot::GetModifiers
okutil_get_ocolor_by_col

Header to Include

origin.h