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
 Using Categorical Data

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
woodpecker Posted - 06/23/2015 : 03:14:05 AM
I have been having trouble using and understanding how to access properties of categorized data using OriginC script.

I have been helping write a function in which I can plot categorical data from different worksheets on the same graph. I can do this all by hand in the Origin interface (by categorizing the data and then using the categories tab from the column properties to make sure all columns use the same CategoricalMap and thus recognize the same categories). But I cannot seem to find the correct OriginC functions to write an algorithm that can do this for me.

Specifically, this is what I am trying to do:
I set all the desired columns to categorical using the .SetAsCategorical() function from the Column class. I then create a CategoricalMap object using .GetCategoricalMap() function (again from the column class) on the first column which will have all the categories I want in the CategoricalMap.
Then here lies the problem. I want to set the other columns to the same CategoricalMap since they often have missing categories in their column that I need them to recognize in order to plot the data on the same graph. However, there does not seem to be any .SetCategoricalMap(CategoricalMap x) function associated with Columns. Is there some way to set a CategoricalMap like this?
If not, I have also thought about adding the categories that may be missing to an "incomplete" CategoricalMap, however the CategoricalMap class does not seem to have any getters or setters for its components (the categories). It does seem to have a lienar search that can return the index of a category that the map contains, but I cannot return the name of the category itself, nor can I add a category to the map.

Are there functions in or outside of the Column or CategoricalMap classes that can help me give my columns all the same categories?

For reference, here are links to the resources I am using for the Column class (http://www.originlab.com/doc/OriginC/ref/Column-Class) and the CategoricalMap class (http://www.originlab.com/doc/OriginC/ref/CategoricalMap).

Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2015 (64-bit) Sr2
Operating System: Windows 7 enterprise

Sincerely,
Matt
2   L A T E S T    R E P L I E S    (Newest First)
woodpecker Posted - 06/26/2015 : 05:28:44 AM
Thank you very much.
This worked very well!

Matt
jasonzhao Posted - 06/24/2015 : 05:29:33 AM
Hello,

Please refer to the example below:

void MyCategoricalMap()
{ 
    Worksheet wks=Project.ActiveLayer();
    if (wks)
    { 
		vector<string> vstrKey={"aa", "cc", "bb", "dd"};  //design your own categories map
		for(int ii=0;ii<5;ii+=2){
		wks.Columns(ii).SetAsCategorical(CMT_NOMINAL); //set column into categorical with normal mode
                wks.Columns(ii).GetCategoricalMap().ReplaceMap(vstrKey);  //update the categorical map
		}       
    }
}

and the worksheet and graph after execute:



Best regards!
Jason
OriginLab Technical Service

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