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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 change contour plot details in Labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vistec

Posts

Posted - 03/16/2006 :  03:14:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR4
Operating System: Win XP

Hello All

I have created a contour plot from a Matrix.
Changing the plot details in Origin works well.
Now I look for an opportunity to change the plot details via Labtalk.
In the "Set levels" dialog box from the "Colormap/contours" options in the plot details I want to change the "Interval" or "Num. of Levels" entry. In the Programming help I have looked under the layer.cmap object, but did not find such a command. Furthermore there is an easy opportunity to solve this in OriginC ?

Thanks

Edited by - vistec on 03/16/2006 03:15:07 AM

easwar

USA
1965 Posts

Posted - 03/16/2006 :  11:00:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There is better access to this in Origin C than LabTalk. Please see the example "Customize Contour Plot" under Graphing category, on this code examples page:
http://www.originlab.com/index.aspx?s=9&lm=71&pid=268

Easwar
OriginLab



Edited by - easwar on 03/16/2006 11:00:47 AM
Go to Top of Page

vistec

Posts

Posted - 03/17/2006 :  02:44:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi easwar,

thanks for your help. I have called the link you
mentioned.But under the graphing category I can 't find the example
"Customize Contour Plot". I called the link at 03/17/2006 : 02:44:50 AM , maybe the page has been changed and this example has been removed? If so, where can I get the information?

Thanks

Edited by - vistec on 03/17/2006 02:46:09 AM

Edited by - vistec on 03/17/2006 02:48:16 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/17/2006 :  06:59:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The View and Download links both work fine now.

Mike Buess
Origin WebRing Member
Go to Top of Page

easwar

USA
1965 Posts

Posted - 03/17/2006 :  09:17:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Thanks for checking the link.

Hi vistec,

This was put up many days ago and not sure why you could not see it - perhaps you were looking at a cached page and needed to refresh?

Anyway, I have pasted the code here in case you still have problems accessing it.

Easwar
OriginLab



#include <Origin.h>

/////////////////////////////////////////////////////////////////////////////////
// This example shows how to change various settings of contour plot.
// NOTE: It is assumed that a graph layer with a contour plot is active.
//
void customize_contour_plot()
{
// Point to active contour plot and check validity
GraphLayer gly = Project.ActiveLayer();
DataPlot dp = gly.DataPlots(-1);
if( !dp ) return;

// Get color map into tree object
Tree tr;
if( !dp.GetColormap(tr) )
return;
// Uncomment next line to dump tree in script window to see what is available
//out_tree(tr);
// You can also examine tree from the Save Theme dialog by editing theme

// Get current contour levels
vector vLevels;
vLevels = tr.Details.Levels.dVals;
// Uncomment next two lines to dump current levels
//for(int i = 0; i < vLevels.GetSize(); i++)
// printf("%d %f\n", i, vLevels[i]);

// Now let us change levels, colors etc
// Following code uses some sample numbers for each
// Modify code as applicable to your data

// Set new min, max (arbitrary numbers, change as needed for your data)
double dMin = -5;
double dMax = 5;

// Change number of levels and values (arbitrary, change as needed)
// In this example we are setting to a nonlinear scale, 2nd order polynomial
int nLevels = 32;
vLevels.SetSize(nLevels);
for(int i = 0; i < nLevels; i++)
{
// Note that level needs to be set as % of (max-min)
vLevels[i] = 100 * (i^2)/(nLevels^2);
// Actual value in dialog/GUI will be:
//printf("%f\n", dMin + vLevels[i]*(dMax-dMin)/100);
}

// Write new level info to tree
tr.Min.dVal = dMin;
tr.Max.dVal = dMax;
tr.Details.Levels.dVals = vLevels;

// Now let us set colors for each level, using RGB values
vector<uint> vColors;
vColors.SetSize(nLevels);
// Set colors using some nonlinear function for R, G, B
// Arbitrary, change as desired.
// Could instead read from say a palette file and assign values
for(i = 0; i < nLevels; i++)
{
int nRed = 256* i / nLevels; // linear in R
int nGreen = 256 * i^2 / nLevels^2; // power of 2 in G
int nBlue = 128 + 128 * sin(2 * Pi * i / nLevels) ; // sinusoidal in B
vColors[i] = nRed + 256 * nGreen + 65536 * nBlue + OCOLOR_RGB_BITS;
// The above sets colors using direct RGB values
// The offset OCOLOR_RGB_BITS indicates to Origin to interpret as RGB
}

// Set above and below color values, such as:
tr.Colormap.Details.BelowColor.nVal = 3; // set to 4th color in Origin color list
tr.Details.AboveColor.nVal = 1; // set to 2nd color in Origin color list
// So can use color list index, or RGB as shown previously

// Write colors to tree
tr.Details.Colors.nVals = vColors;

// Set new color map properties using updated tree
if( !dp.SetColormap(tr) )
printf("Failed to set color map\n");

}
//
// Note also that settings can be saved as Theme or entire graph can be saved
// as template for future use with different data, so it is not necessary to
// programmatically modify settings for each case.




Go to Top of Page

vistec

Posts

Posted - 03/20/2006 :  01:44:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi easwar and Mike,

thanks a lot for your help.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000