3.3.11 Image Plot

Version Info

Minimum Origin Version Required: Origin 8 SR0

Example

The following codes show how to plot image plot from matrix with data and how to configure image plot with custom z values and colors.

void Image_Plot()
{
	MatrixLayer ml = Project.ActiveLayer();
	if(!ml)
		return;
	MatrixObject mo = ml.MatrixObjects(0);
	if(!mo)
		return;
	
	GraphPage gp;
	gp.Create("Image"); // need use Image template here
	if(!gp)
		return;
	
	GraphLayer gl = gp.Layers(0);
	int nPlot = gl.AddPlot(mo, IDM_PLOT_MATRIX_IMAGE);
	if(nPlot < 0)
	{
		out_str("Fail to plot image plot");
		return;
	}
		
	vector vLevels;
	const double min = 0;	
	const double max = 50000;	
	const int nLevels = 5;	
	double inc = (max - min) / (nLevels - 1);	
	vLevels.Data(min, max, inc);	
	
	vector<uint> vnColors;	
	vnColors.Data(1, nLevels-1, 1); // must keep vnColors.GetSize() == vLevels.GetSize() - 1
	
    DataPlot dp = gl.DataPlots(nPlot);
	dataplot_set_colormap(dp, vLevels, vnColors);   		
}