The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How can I label my 3D-Bars automatically

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AGSalbeck Posted - 11/17/2004 : 09:36:11 AM
Origin Version (7.5853):
Operating System: WinXP

Hi,
I´ve got a problem with the 3D-Bars.

I measured the thickness of a piece of glass on 16 points. The measure-points are arranged like a chess board with 4 rows and 4 columns. I think the best way to visualize my results is a 3d Bar. So I created a Matrix with 4 * 4 Values. Now I want to label each bar with its value from the matrix. but the only way i found is to do it manually. in future i will measure hundreds of those samples, so it would be much nicer, if i could put in the thickness-value automatically on the top of a bar.

I hope, you can give me some suggestions...

Thanks, Thorsten.
2   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 11/19/2004 : 5:18:47 PM
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 );
}
}
}



Hideo Fujii Posted - 11/18/2004 : 7:13:40 PM
Hi Thorsten,

I don't have totally automated solution. Only comming to my mind was to use the combination of a simple LabTalk command and a Data Readers tool, which may help your work a little bit...

1) Create a tool button which runs the following single LabTalk command:
   label -s $(z);

2) Activate your 3D Bars graph, and click Data Reader tool button in the Tools toolbar.

3) Click the top of a bar where you want to add the Z value label; then click(run) the tool button which you created at 1). This will add the Z value label to the position. Repeat this step for all bars.

Hope this makes your life a little bit easier...

--Hideo Fujii
OriginLab


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000