{"id":1864,"date":"2015-04-15T13:10:21","date_gmt":"2015-04-15T17:10:21","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=1864"},"modified":"2019-10-16T15:19:32","modified_gmt":"2019-10-16T19:19:32","slug":"unstack-and-stack-columns","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/unstack-and-stack-columns","title":{"rendered":"Unstack and Stack Columns"},"content":{"rendered":"<p>Sometimes your imported data may not be able to be used directly to plot certain graph or do certain analysis. Origin provides multiple ways to transform your data. This post will show you an example of unstacking columns so as to plot multi-panel graphs based\u00a0on labels of columns.<\/p>\n<p>Please download the opj file:\u00a0<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/UnstackStack_Cols1.zip\">Unstack&amp;Stack_Cols<\/a><\/p>\n<p>Go to Folder1 to play with sample data:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1867 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_1.png\" alt=\"DOC-2358_1\" width=\"400\" height=\"452\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_1.png 400w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_1-265x300.png 265w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>XY data is in Col(A) and Col(B), and indexing or grouping information is in Col(C) and Col(D). We want to plot a multi-panel graph, each <strong>Treatment<\/strong> in one panel.<\/p>\n<p><strong><span style=\"color: #0000ff;\">Note: we introduced <a style=\"color: #0000ff;\" href=\"https:\/\/www.originlab.com\/doc\/Origin-Help\/Trellis-Plot\">Trellis Plot<\/a> in Origin 2017 which plots data with grouping information into multiple panels directly. So user doesn&#8217;t need to unstack columns first.\u00a0<\/span><\/strong><\/p>\n<p>First, let&#8217;s unstack XY data\u00a0into categories of Gender and Treatment at different columns.<\/p>\n<p>Highlight Col(A) and Col(B) in the worksheet, then go to menu <strong>Worksheet: Unstack Columns: Open Dialog<\/strong>. Add\u00a0<strong>Group Column(s)<\/strong> to be <strong>D(Y) : Treatment<\/strong> \u3001 <strong>C(Y) : Gender<\/strong>\u00a0successively. And select<strong>\u00a0Put Grouping Info. to <\/strong>be <strong>User Defined Parameters\u00a0<\/strong>so that <strong>Long Name<\/strong> from group columns will be appended on output columns.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1907 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_21.png\" alt=\"\" width=\"721\" height=\"502\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_21.png 721w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_21-300x209.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>The\u00a0order of Group columns controls the level of category, and it can be adjusted using these buttons\u00a0<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1869\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_3.png\" alt=\"DOC-2358_3\" width=\"74\" height=\"18\" \/><\/a>. If you have other columns to include in the unstacked worksheet, just check the <strong>Include Other Columns(s)<\/strong> checkbox under <strong>Options<\/strong>, and select data similarly.<\/p>\n<p>Click OK, and unstacked data will be appended in a new worksheet, and labels will append on newly added header rows.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1908 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_31.png\" alt=\"\" width=\"655\" height=\"283\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_31.png 655w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_31-300x130.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Then the data will be ready for example for a multi-panel scatter plot. Just highlight entire worksheet, and go to menu <strong>Plot: Multi-Panel: Multiple Panels By Labels<\/strong>, and choose settings as following:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1909 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_7.png\" alt=\"DOC-2358_7\" width=\"409\" height=\"361\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_7.png 409w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_7-300x265.png 300w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/a><br \/>\nThen, just further customize Axis, Layer and legend to have a graph\u00a0as following. Please go to Result folder\u00a0to view as well.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_55.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1910 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_55.png\" alt=\"\" width=\"414\" height=\"576\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_55.png 414w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_55-216x300.png 216w\" sizes=\"auto, (max-width: 414px) 100vw, 414px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Besides, if your data doesn&#8217;t have indexing columns and you want to use row indexing as grouping, then you can use the x function <strong>colsplit<\/strong> to unstack columns. Run following script:<\/p>\n<pre class=\"lang:default decode:true\">colsplit -d;<\/pre>\n<p>It will open the following dialog, where you can either unstack <strong>By Every Nth Row<\/strong>, or By<strong> Sequential N Rows<\/strong>.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1882 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_6.png\" alt=\"DOC-2358_6\" width=\"428\" height=\"327\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_6.png 428w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2358_6-300x229.png 300w\" sizes=\"auto, (max-width: 428px) 100vw, 428px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Stacking columns from menu <strong>Worksheet: Stack Columns<\/strong>\u00a0is\u00a0the the reverse operation of unstack columns.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Sometimes your imported data may not be able to be &hellip; <\/p>","protected":false},"author":16,"featured_media":2084,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3],"tags":[],"class_list":["post-1864","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-handling"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7DvU2-u4","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/Review-image.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=1864"}],"version-history":[{"count":12,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1864\/revisions"}],"predecessor-version":[{"id":11335,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1864\/revisions\/11335"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/2084"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=1864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=1864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=1864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}