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
 Forum for Origin C
 Plot, color, legend !
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

billaravi

USA
14 Posts

Posted - 05/17/2005 :  01:59:53 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.0):
Operating System:XP Pro

Hi
Iam using the following code to plot data from different xy columns of a worksheet into a single layer of a graph. How can make a plot so that each set of xy data is displayed in a different color on the plot.

Also i would like add a legend to the plot after adding every xy dataset to the plot.

many thanks in advance
ravi

// Create a graph using custom template
GraphPage grphData;
string strGrphTemplate = strProjectPath + "Automate.otp";
int nOptionG = CREATE_VISIBLE_SAME;
bool bRetG = grphData.Create(strGrphTemplate, nOptionG);

int i;

for(i=0; i<=ncols-1; i=i+2)
{
// Declare a curve object using x,y columns of worksheet
Curve crvData(wksData, i, i+1);

// Declare active layer in current graph page
GraphLayer grphLayer = grphData.Layers();

// Plot data curve to active layer
int nPlot = grphLayer.AddPlot(crvData, IDM_PLOT_SCATTER);
grphLayer.Rescale();
};

easwar

USA
1965 Posts

Posted - 05/17/2005 :  09:54:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

One way to make the group plot is to add the entire worksheet to the layer instead of one curve at a time, and this will work fine if your worksheet is set up with column designations such as XYXYXY...etc which seems to be the case here.

So you could code it as:

GraphLayer grphLayer = grphData.Layers();
grphLayer.AddPlot(wksData, IDM_PLOT_SCATTER);
grphLayer.Rescale();
grphLayer.LT_execute("legend;");



Note that in the above code segment, the add legend to the graph, the "legend" script command is being issued - there is no direct access to legend from OC at this point.

Now, if you wish to add one plot at a time, you can still do that and then after adding all plots, you can use the GroupPlots() method of GraphLayer class to group them, and then follow up with the script legend command to add/update legend.

Easwar
OriginLab

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