| T O P I C R E V I E W |
| liujibao |
Posted - 02/18/2004 : 10:13:35 PM There is a beautiful sample graph-"3D Scatter 2.opj" in the directory "..\OriginLab\OriginPro75\Samples\Graphing\3D Plots", I just want to learn how to realize it with origin c for my more ideal works , but I have never tried plotting 3D graph wiht origin c before. Can it be realized with origin c? where are there some sample-codes about it? |
| 9 L A T E S T R E P L I E S (Newest First) |
| Iris_Bai |
Posted - 02/22/2004 : 10:05:13 PM Sorry, I modified the codes, could you try it again? Please create a Template named "Complex.otp" with two 3D layers and one 2D layer and save it under user path firstly.
int sample(string strWksName) { Worksheet wks(strWksName); if(!wks) { printf("%s is not exist in current project", strWksName); return 0; } GraphPage gp; gp.Create("Complex", CREATE_VISIBLE_SAME); if(!gp) { return 0; } ///////3D Scatter plot GraphLayer gl; gl = gp.Layers(0);//Layer 1 is 3D SCATTER, Curve cv(wks,1 ,2); int nIndex = gl.AddPlot(cv ,ID_3D_GRAPH_SCATTER); DataPlot dp; dp = gl.DataPlots(nIndex); printf("Plot %d is 3D SCATTER!\n", nIndex); ///////Setup Layer1 Tree trLayer; gl.GetLayerContents(trLayer); //Set X, Y and Z axis range gl.XAxis.Scale.From.nVal = 0; gl.XAxis.Scale.To.nVal = 70; gl.XAxis.Scale.Value.dVal = 10; //Increment gl.YAxis.Scale.From.nVal = 15; gl.YAxis.Scale.To.nVal = 17.5; gl.YAxis.Scale.Value.dVal = 1; gl.ZAxis.Scale.From.nVal = 0; gl.ZAxis.Scale.To.nVal = 24; gl.ZAxis.Scale.Value.dVal = 5; //Set Symbol size, shape, etc. Tree trCurve; trCurve = dp.Curve; trCurve.Symbol.Size.nVal = 5; trCurve.Symbol.Shape.nVal = 2; trCurve.Symbol.Interior.nVal = 1; trCurve.Symbol.EdgeColor.nVal = 3; trCurve.Symbol.EdgeWidth.nVal = 255; // trCurve.DropLines.Z.nVal = 1; trCurve.DropLines.Color.nVal = 20; trCurve.DropLines.width.nVal = 5; dp.Curve = trCurve; gl.Rescale(); ///////Add 3D TRAJECTORY plot GraphLayer gl2; gl2 = gp.Layers(1);//Layer 2 is 3D TRAJECTORY, // Curve cv2(wks, 1, 2); gl2.AddPlot(cv ,ID_3D_GRAPH_TRAJECTORY); gl2.Rescale(); ///////Add 2D Scatter plot GraphLayer gl3; gl3 = gp.Layers(2); Curve cv3(wks, 0, 1); gl3.AddPlot(cv3, IDM_PLOT_SCATTER); gl3.Rescale(); return 1; }
|
| cpyang |
Posted - 02/21/2004 : 10:58:23 AM Iris's code above is using LabTalk to create a new graph from worksheet, which is not the best way to make a graph in Origin C. To make a more complex graph, you should create that graph in Origin by hand first, then save the template. In your OC code, you can bring in that template and add plots to each layer.
To make a graph with both 2D and 3D layers, just create the separate graphs and then from
Edit : Merge All Graph Windows
to create the new combined graph. Then you resize the various layers to the way you want, and save this template with a name, lets call it "MyGraph". Make sure you save this template into the User Files path, the same location as other Origin templates (*.otp).
In OC, you can do things like
GraphPage gp; gp.Create("MyGraph", CREATE_VISIBLE_SAME);
I will post more complete codes later, or maybe Iris can modify her code example to create the graph from OC rather then using LabTalk.
CP
Edited by - cpyang on 02/21/2004 11:11:26 AM |
| liujibao |
Posted - 02/21/2004 : 02:40:10 AM another question: when I had create such a template,how to use it ? In fact, I haven't find how to create it! I am trying. |
| liujibao |
Posted - 02/21/2004 : 12:09:29 AM First,Thanks you for your reply! Then ,I have an another question: I want to create mutilayers, There are 2D and 3D graphs, but the command "wks.LT_execute("worksheet -P 240 3d")" only create new graphpage layer, how to realize my idea?
for example:I want to create three layers,one is 3D Scatter, one is 2D Scatter, and another is 3D Trajectory.
It can be realized? I have searched such a sample for a long time, but finded none. Will you help me?
Edited by - liujibao on 02/21/2004 02:37:04 AM |
| Mike Buess |
Posted - 02/19/2004 : 10:22:07 AM LabTalk.wks.colsel(1,1); LabTalk.wks.colsel(3,1); LabTalk.wks.colsel(5,1);
Mike Buess Origin WebRing Member |
| liujibao |
Posted - 02/19/2004 : 09:23:23 AM why isn't there the function GetSelectedColumns? How to realize to select the uncontinuous Columns,such as 1,3,5 column ?
The command "worksheet -s " only selects single or continuous columns. |
| Iris_Bai |
Posted - 02/19/2004 : 03:48:41 AM As for other layer settings, maybe need LabTalk command, so I just give you the codes above using Origin C.
Iris |
| Iris_Bai |
Posted - 02/19/2004 : 03:45:54 AM Please make sure there is worksheet with XYZ data in the current window before running following code.
int smaple(string strWksName) { Worksheet wks(strWksName); if(!wks) { printf("%s is not exist in current project", strWksName); return 0; } if(!wks.GetPage().Show()) wks.GetPage().SetShow(); vector<int> vnSelCols; wks.GetSelectedColumns(vnSelCols); bool bZCol = false; for(int ii=0; ii<vnSelCols.GetSize(); ii++) { if(OKDATAOBJ_DESIGNATION_Z == wks.Columns(vnSelCols[ii]).GetType()) bZCol = true; } if(0 == ii || !bZCol ) { MessageBox(GetWindow(), "Please select one Z column first!","Note"); return 0; }
wks.LT_execute("worksheet -P 240 3d");//make a 3D Scatter plot GraphLayer gl = Project.ActiveLayer(); if(!gl) { return 0; } Tree trLayer; gl.GetLayerContents(trLayer); //Set X, Y and Z axis range gl.XAxis.Scale.From.nVal = 0; gl.XAxis.Scale.To.nVal = 70; gl.XAxis.Scale.Value.dVal = 10; //Increment gl.YAxis.Scale.From.nVal = 15; gl.YAxis.Scale.To.nVal = 17.5; gl.YAxis.Scale.Value.dVal = 1; gl.ZAxis.Scale.From.nVal = 0; gl.ZAxis.Scale.To.nVal = 24; gl.ZAxis.Scale.Value.dVal = 5; //Set Symbol size, shape, etc. DataPlot dp = gl.DataPlots(0); Tree trCurve; trCurve = dp.Curve; trCurve.Symbol.Size.nVal = 5; trCurve.Symbol.Shape.nVal = 2; trCurve.Symbol.Interior.nVal = 1; trCurve.Symbol.EdgeColor.nVal = 3; trCurve.Symbol.EdgeWidth.nVal = 255; // trCurve.DropLines.Z.nVal = 1; trCurve.DropLines.Color.nVal = 20; trCurve.DropLines.width.nVal = 5; dp.Curve = trCurve; return 1; }
Iris |
| liujibao |
Posted - 02/19/2004 : 03:17:27 AM Will nobody help me?
 |
|
|