Author |
Topic  |
|
5*10
Germany
Posts |
Posted - 08/23/2005 : 05:19:16 AM
|
Origin Version (Select Help-->About Origin): 7G SR4 v.7.0552 Operating System:win 2000
Hi,
is there any possability to plot the data of a vector directly. Because I want to loop over several vector, plot one of them in a graphlayer and overwrite this plot with the next plot of the next vector. If it isnt possible to do this, i have to write a loop in Labtalk, write every vector in an wks and plot it. This costs much time.
5*10 |
|
Mike Buess
USA
3037 Posts |
Posted - 08/23/2005 : 07:41:20 AM
|
Help > Origin > Plotting Origin's Built-in Graph Types > Vector Graphs
Mike Buess Origin WebRing Member |
 |
|
easwar
USA
1965 Posts |
Posted - 08/23/2005 : 10:38:09 AM
|
Hi 5*10,
If you were referring to plotting data that is in vector objects in OC...
To make a plot you need both X and Y and thus a curve. And the curve has to be constructed from datasets attached to dataset columns in a worksheet...
So you could use a hidden worksheet that you repeatedly use, from OC, with code such as below:
Easwar OriginLab
void plot_vec() { // Create and keep a hidden worksheet with X, Y datasets WorksheetPage wpg; wpg.Create("Origin", CREATE_HIDDEN); Worksheet wks = wpg.Layers(0); Dataset dsX(wks, 0); Dataset dsY(wks, 1); // Create a new graph page, or use existing one GraphPage gpg; gpg.Create("Origin"); GraphLayer gly = gpg.Layers(0); // say you have a vector with some values, such as: vector vecY = {1, 4, 5, 7, 8, 5, 5, 4, 3, 2, 9}; // You could change the following to loop over all your vectors... // create an x vector with "row numbers", same size as vecY vector vecX; vecX.Data(1, vecY.GetSize(), 1); // Copy these vectors to hidden wks dsX = vecX; dsY = vecY; // Create a curve from the datasets and plot the curve Curve crv(wks, 0, 1); // Plot the curve gly.RemovePlot(0); // remove previous plot if plotting repeatedly gly.AddPlot(crv); gly.Rescale(); }
|
 |
|
easwar
USA
1965 Posts |
Posted - 08/23/2005 : 10:46:56 AM
|
Hi 5*10,
In the previous post I was suggesting creating corresponding X vector. That is actually not required. If you have just a Y col and no X col, Origin would automatically plot against row number, so the code could be simplified such as below:
Easwar OriginLab
void plot_vec2() { // Create and keep a hidden worksheet with just one Y column WorksheetPage wpg; wpg.Create("Origin", CREATE_HIDDEN); Worksheet wks = wpg.Layers(0); // Delete all cols and add just one Y col while( wks.DeleteCol(0) ); wks.AddCol(); Dataset dsY(wks, 0); // Create a new graph page, or use existing one GraphPage gpg; gpg.Create("Origin"); GraphLayer gly = gpg.Layers(0); // say you have a vector with some values, such as: vector vecY = {1, 4, 5, 7, 8, 5, 5, 4, 3, 2, 9}; // You could change the following to loop over all your vectors... // Copy the Y vector to the wks col dsY = vecY; // Create a curve from the datasets and plot the curve Curve crv(wks, 0); // Plot the curve gly.RemovePlot(0); // remove previous plot if plotting repeatedly gly.AddPlot(crv); gly.Rescale(); }
|
 |
|
5*10
Germany
Posts |
Posted - 08/24/2005 : 03:19:18 AM
|
Thank you, the function works, but there are problems wit the "RemovePlot" function. Origin 7 is not able to compile this!! Is this function still implemnted in origin 7.0 pro or is it a funtion of Origin 7.5 pro?? |
 |
|
5*10
Germany
Posts |
Posted - 08/24/2005 : 04:46:14 AM
|
Hi,
I just tested it without the remove function and it works either! So do not need this function!! Thanks for your help!! |
 |
|
|
Topic  |
|
|
|