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
 Colouring Dot Plots
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wallacej

UK
Posts

Posted - 01/28/2005 :  08:53:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.5):
Operating System:Windows 2000

I have a LabTalk script that creates a 3D surface plot from my data. (length, shape, frequency) (X, Y, Z).

I also have a LabTalk script that creates a 2D scatter plot from the same data. (length, shape) (X, Y).

I would like to colour each of the dots in the 2D graph according to a scale based on the Z values from my data.

A result very similar to the contour plot is desirable, but it is important to still have the actual dots displayed.

Thank You

easwar

USA
1965 Posts

Posted - 01/28/2005 :  4:50:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Here is an Origin C solution that creates the scatter plot from cols 1,2 of the wks and uses col 3 to set the color map of the scatter points. Once such a function is compiled and ready, you can call it from your LabTalk script or from the Script Window.


void plot_symbol_color_map()
{
// Assumes worksheet with three columns set to
// X, Y, Z where z column contains data to be used
// for color map
//
// Declare worksheet from active layer
Worksheet wks = Project.ActiveLayer();
// Create a new graph page
GraphPage gpg;
gpg.Create();
// Point to layer 1
GraphLayer gly = gpg.Layers(0);
// Make a curve object from cols 1, 2 of wks
Curve crv(wks, 0, 1);
// Plot curve as scatter plot
gly.AddPlot(crv, IDM_PLOT_SCATTER);
// Point to the data plot object for the plot
DataPlot dp = gly.DataPlots(0);
// Change the edge color setting to color map based on col 3
dp.Curve.Symbol.EdgeColor.nVal = 4194405;
// Rescale the layer
gly.Rescale();
}



In the above code, the Edge Color property is set to the value 4194405 which means "use color mapping and get the mapping values from the column right next to the Y column". Currently there are no constants defined for such values. You can determine what value to use by first making an instance of the graph manually in the GUI, and then running code such as below which gets the plot properties to a tree and then dumps the properties to the script window.


void dump_plot_properties()
{
GraphLayer gly = Project.ActiveLayer();
DataPlot dp = gly.DataPlots(0);
Tree tr;
tr = dp.Curve.Symbol;
out_tree(tr);
}



Easwar
OriginLab


Go to Top of Page

wallacej

UK
Posts

Posted - 01/31/2005 :  05:19:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank You for that help, I'll let you know how I get on.

Thanks
Go to Top of Page

wallacej

UK
Posts

Posted - 02/01/2005 :  12:37:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm having some problems with the above code. My data isn't exactly in three adjacent columns x,y,z. I used this terminology for descriptive purposes.

The data is in a large worksheet. x is in column 1, y is column 4 and Z is generated by a calculation, ie to get the frequency. Because of this reason I am having trouble using the colour mapping as supplied, presumably because it uses the value that:

"use color mapping and get the mapping values from the column right next to the Y column".

Anymore ideas?

Thank You for your time
Go to Top of Page

easwar

USA
1965 Posts

Posted - 02/01/2005 :  3:40:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The values you want to use or indexing does not have to be in the column right next to the Y column, but needs to be in the same worksheet in a later column. So say the worksheet is set up such that X, Y are in cols 1, 2 and Z/color index is in col 10.
So the color column is the 8th col to the right of the Y column.
In this case, you will then need to change the code to:
dp.Curve.Symbol.EdgeColor.nVal = 4194404 + 8;

Easwar
OriginLab




Edited by - easwar on 02/01/2005 3:43:54 PM
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