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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Customizing a set of graphs

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
a.abc.b35 Posted - 05/17/2011 : 10:07:32 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8, SR0
Operating System: Windows 7
..............
I am trying to run the following code :
**code pasted at end**
Now the problem is, the code runs properly, plots the graphs also but without changing the symbol shapes,sizes etc ( which I try to access by the Tree trFormat). Can someone help me here ?

#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////
// It graphs a workbook as below:
// It takes 2 integer parameters, which are column numbers.
// 1st input column is X, 2nd is Y


////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.
void GraphWorkBookXY(int ic1,int ic2)
{
	// enter Workbook whose worksheets are to be graphed
	string wpName = InputBox("Please enter the WorkBook name which is to be graphed", "data");
	if(wpName.IsEmpty())  // executed if user does not enter anything in the InputBox pop up window
    {
      	printf("Try again.You enetered empty space.Operation Cancelled!\n");
      	return;
    } 
    WorksheetPage wp(wpName);
    
    // loop all worksheets in the workbook, add plots to graph
    for(int iwks = 0; iwks <wp.Layers.Count();iwks++)
    {
    	Worksheet wks = wp.Layers(iwks);
    	if(wks.IsValid())
        {
            GraphPage gp;
            gp.Create("Origin");  // create graph page
             
           	string gpName,wksName; // used to name a graph page
           	wksName = wks.GetName(); // name of worksheet
           	gpName.Format("%s%s%s",wpName,"_",wksName.Right(3)); // this is name of the graph page
           	gp.SetName(gpName);  // set graph page name
            
            GraphLayer gl = gp.Layers(0);  // get graph layer in graph page
            
            if(gl)
    		{
            	DataRange dr;
            	dr.Add(wks,ic1-1, "X");	// X data range
            	dr.Add(wks,ic2-1, "Y");	// Y data range
                        
            	//the internal Origin plot type id, see IDM_PLOT_* in oPlotIDs.h.
            	gl.AddPlot(dr, IDM_PLOT_SCATTER);  // add scatter plot
            
            	gl.GroupPlots(0);  // group all plots in the graph layer
            	gl.Rescale(ANL_NO_ROUNDING);  // rescale graph layer
                        
 
        		// Get the first data plot in the layer:
        		DataPlot        dp = gl.DataPlots(0);
 
        		// Set the color to black and repaint:
        		dp.SetColor(0, TRUE);
        	
    			Tree trFormat;
            	trFormat.Root.Symbol.Shape.nVal = 5;  // set shape: diamond
            	trFormat.Root.Symbol.Interior.nVal = 1;  // interior: empty
            	trFormat.Root.Symbol.Size.nVal = 12;  // set size: 12
    		
    		}
        	
        	printf("Graph page: %i.\tName of Graph page: %s.\n",iwks+1 ,gp.GetName());  // name of graph page
        }
    } 
}


AB
7   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 05/22/2011 : 9:42:16 PM
Hi,

You can get the format tree of the axis, and then print it out to see the structure of the format tree. For more details, please refer to the serial of examples on axis format.

Penn
a.abc.b35 Posted - 05/22/2011 : 02:25:06 AM
Also, how do I set the increments on Y and X scale and also the number of minor ticks on the scale ?

AB
a.abc.b35 Posted - 05/22/2011 : 02:17:21 AM
I have one more question, I need to set the Y scale range from 0 to 1. How can I do it by the tree Node method above, for a series of graphs ?

AB
a.abc.b35 Posted - 05/18/2011 : 1:03:02 PM
Thanks a lot Penn. It works !!
...........
@ rlewis ; I tried your method also but it gives me errors ! I suppose it has something to do with the origin version I am using.

AB
Penn Posted - 05/18/2011 : 02:06:11 AM
Hi,

In your code, you have not apply the format to the plot yet. You need to use the UpdateThemeIDs and ApplyFormat methods to do that. So, you need to add more lines to do that, such as (pay attention to the red lines):

void GraphWorkBookXY(int ic1,int ic2)
{
	// enter Workbook whose worksheets are to be graphed
	string wpName = InputBox("Please enter the WorkBook name which is to be graphed", "data");
	if(wpName.IsEmpty())  // executed if user does not enter anything in the InputBox pop up window
    {
      	printf("Try again.You enetered empty space.Operation Cancelled!\n");
      	return;
    } 
    WorksheetPage wp(wpName);
    
    // loop all worksheets in the workbook, add plots to graph
    for(int iwks = 0; iwks <wp.Layers.Count();iwks++)
    {
    	Worksheet wks = wp.Layers(iwks);
    	if(wks.IsValid())
        {
            GraphPage gp;
            gp.Create("Origin");  // create graph page
             
           	string gpName,wksName; // used to name a graph page
           	wksName = wks.GetName(); // name of worksheet
           	gpName.Format("%s%s%s",wpName,"_",wksName.Right(3)); // this is name of the graph page
           	gp.SetName(gpName);  // set graph page name
            
            GraphLayer gl = gp.Layers(0);  // get graph layer in graph page
            
            if(gl)
    		{
            	DataRange dr;
            	dr.Add(wks,ic1-1, "X");	// X data range
            	dr.Add(wks,ic2-1, "Y");	// Y data range
                        
            	//the internal Origin plot type id, see IDM_PLOT_* in oPlotIDs.h.
            	gl.AddPlot(dr, IDM_PLOT_SCATTER);  // add scatter plot
            
            	gl.GroupPlots(0);  // group all plots in the graph layer
            	gl.Rescale(ANL_NO_ROUNDING);  // rescale graph layer
                        
 
        		// Get the first data plot in the layer:
        		DataPlot        dp = gl.DataPlots(0);
 
        		// Set the color to black and repaint:
        		dp.SetColor(0, TRUE);
        	
    			Tree trFormat;
            	trFormat.Root.Symbol.Shape.nVal = 5;  // set shape: diamond
            	trFormat.Root.Symbol.Interior.nVal = 1;  // interior: empty
            	trFormat.Root.Symbol.Size.nVal = 12;  // set size: 12
    			
            	// 
            	if(0==dp.UpdateThemeIDs(trFormat.Root))
            	{
            		dp.ApplyFormat(trFormat, true, true);
            	}
    		}
        	
        	printf("Graph page: %i.\tName of Graph page: %s.\n",iwks+1 ,gp.GetName());  // name of graph page
        }
    } 
}


Penn
rlewis Posted - 05/18/2011 : 12:43:15 AM
Try modifyng your code to something like ...

Tree trFormat=gl.GetFormat(FPB_ALL,FOB_ALL,true, true);
trFormat.Root.Symbol.Shape.nVal = 5;  // set shape: diamond
trFormat.Root.Symbol.Interior.nVal = 1;  // interior: empty
trFormat.Root.Symbol.Size.nVal = 12;  // set size: 12
gl.ApplyFormat(trFormat,true,true);
a.abc.b35 Posted - 05/17/2011 : 10:09:45 PM
One more info : Whatever number I change in the trFormat part, I always get the default black square (filled) with size 9 as the symbol on my graph. Please help.

AB

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000