Hi Thorsten,
Currently there is no mechanism to place labels in 3D that stay attached to the 3D position, such as it stays in place when figure is rotated or x/y scale is changed etc.
You may want to take a look at Image Plot - you can create this from a matrix using the Plot->Image Plot menu when matrix is active. If you mostly work with 4x4 or such small matrices, the code pasted below will create an Image Plot and will automatically place labels with Z value in each cell, as shown in figure below.
To try the code, open a new C file in Code Builder, copy-paste the code from here, then compile and link. Then go to Origin, make your matrix active, and enter the command
image_plot_with_labels
in the script window and hit enter.
To make this command/function available in every session, you can go to Code Builder, use the workspace tree on the left, and drag-and-drop the newly created file from the User branch to the System branch.
Easwar
OriginLab

// Create image plot and label each cell/pixel with corresponding z value
void image_plot_with_labels()
{
// Declare active layer as matrix and check validity
MatrixLayer matLy = Project.ActiveLayer();
if( !matLy )
{
out_str( "Active layer is not a matrix!" );
return;
}
// Change internal data type to double, and declare Matrix object
matLy.SetInternalData(FSI_DOUBLE);
Matrix<double> Mat( matLy );
// Get matrix dimensions and start/end/step values for x, y
int iNumRows = Mat.GetNumRows();
int iNumCols = Mat.GetNumCols();
double dXMin, dXMax, dYMin, dYMax;
dXMin = Mat.GetXMin();
dXMax = Mat.GetXMax();
dYMin = Mat.GetYMin();
dYMax = Mat.GetYMax();
double dXStep, dYStep;
dXStep = ( dXMax - dXMin ) / ( iNumCols - 1 );
dYStep = ( dYMax - dYMin ) / ( iNumRows - 1 );
// Create an image plot using default image template
GraphPage gPg;
gPg.Create( "IMAGE" );
GraphLayer gLy = gPg.Layers( 0 );
// Declare matrix object and plot in layer
MatrixObject matObj = matLy.MatrixObjects();
gLy.AddPlot( matObj, IDM_PLOT_MATRIX_IMAGE );
// Set x, y axes limits correctly
Axis axX = gLy.XAxis;
Axis axY = gLy.YAxis;
axX.Scale.From.dVal = dXMin - dXStep / 2;;
axX.Scale.To.dVal = dXMax + dXStep / 2;
axY.Scale.From.dVal = dYMin - dYStep / 2;
axY.Scale.To.dVal = dYMax + dYStep / 2;
// Change scale settings for x, y axes
axX.Scale.IncrementBy.nVal = 1;
axX.Scale.MajorTicksCount.nVal = iNumCols + 1;
axY.Scale.IncrementBy.nVal = 1;
axY.Scale.MajorTicksCount.nVal = iNumRows + 1;
// Now loop over all cells and add labels using z value of cell
double dLabelXPos, dLabelYPos;
string strLabelName, strLabelValue, strCMD;
// For each row...
for( int ir = 0; ir < iNumRows; ir++ )
{
// Compute y pos of label
dLabelYPos = dYMin + dYStep * ir;
// For each column...
for( int ic = 0; ic < iNumCols; ic++ )
{
// Compute x pos of label
dLabelXPos = dXMin + dXStep * ic;
// Set up label object name and label string value
strLabelName.Format( "C%2.2d%2.2d", ir, ic );
strLabelValue.Format( "%5.2f", Mat[ir][ic] );
// Place label at computed x, y position - need to use LabTalk
strCMD.Format( "label -a %f %f -n %s %s;", dLabelXPos, dLabelYPos, strLabelName, strLabelValue );
LT_execute( strCMD );
// Set label color to red
strCMD.Format( "%s.color = 2;", strLabelName );
LT_execute( strCMD );
// Set label to be not selectable with mouse
strCMD.Format( "%s.mouse = 0;", strLabelName );
LT_execute( strCMD );
}
}
}