{"id":2887,"date":"2015-06-05T10:00:44","date_gmt":"2015-06-05T14:00:44","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=2887"},"modified":"2019-11-18T12:49:14","modified_gmt":"2019-11-18T17:49:14","slug":"how-to-make-a-contour-plot-of-difference-of-two-contours","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/how-to-make-a-contour-plot-of-difference-of-two-contours","title":{"rendered":"How to make a contour plot of the difference between two contours"},"content":{"rendered":"<p>The following two graphs are the contour plots of Mt. St. Helen and its surrounding area before and after the eruption in 1980. Occasionally people want to calculate the difference of the Z values (in this sample, the altitude) of such two contours, and to make a new contour plot of the difference. If the two contour plots are given as two matrices with the same dimensions, then what is needed to do is simply subtracting a matrix from the other. However, if the the data of the contours are given as XYZ datasets, you need to interpolate datasets to make their rows corresponding each other to make them subtractable from one to the other.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_Graph1.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-2907 size-medium\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_Graph1-280x300.gif\" alt=\"Mt.St.Helen_Graph1\" width=\"280\" height=\"300\" \/><\/a><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_Graph2.gif\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2908 alignleft\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_Graph2-286x300.gif\" alt=\"Mt.St.Helen_Graph2\" width=\"286\" height=\"300\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>You can try the following procedure to produce the contour like Graph3 below by subtracting Graph1 from Graph2 above, using the sample Origin file, which can be downloaded from this <a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/sample_ContourDeltaZ.zip\">link <\/a>.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_Graph3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2979\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_Graph3-300x300.jpg\" alt=\"Mt.St.Helen_Graph3\" width=\"300\" height=\"300\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_Graph3-300x300.jpg 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_Graph3-150x150.jpg 150w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_Graph3.jpg 329w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>[Procedure]<\/strong><\/h4>\n<p>1) In this sample file, you find two workbooks, Book1 and Book2 &#8211; the former contains the XYZ data before the eruption, and the later data after the eruption. First, append the XY data (not Z) (from row 1 to 1600) in Book2, to the end of Book1, after row 1024 as shown in the screenshot below. Do the same to append XY data of row 1 to 1024 from Book1 to Book2.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks01.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2975\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks01-300x298.gif\" alt=\"Mt.St.Helen_wks01\" width=\"300\" height=\"298\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks01-300x298.gif 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks01-150x150.gif 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>2) Now, we make two worksheets have exactly the same XY positions using interpolation. For Book1, select the menu, <strong>Analysis: Mathematics: Interpolate Z from XY.<\/strong><\/p>\n<p>In the <strong>Interpolate Z from XY<\/strong> dialog, click &gt; button next to <strong>XY Values to Interpolate<\/strong> and pick<strong> B(Y)<\/strong>, click &gt; button next to\u00a0<strong>Input<\/strong>\u00a0and pick<strong> C(Z)<\/strong>. Click &gt; button next to \u00a0<strong>Result of Interpolation<\/strong> and pick<strong> C(Z)<\/strong>. Set the <strong>Method<\/strong> of interpolation, for example <strong>Random TPS<\/strong> in this sample. Click <strong>OK<\/strong>. The rows 1025-2624 of <strong>C(Z)<\/strong>\u00a0are filled with values as well. No lock shows in C(Z) because <strong>Input<\/strong> and\u00a0<strong>Result of Interpolation<\/strong>\u00a0are both set to <strong>C(Z)<\/strong>.\u00a0Do the same operations for Book2.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_interp2.gif\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2892 size-medium alignleft\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_interp2-231x300.gif\" alt=\"Mt.St.Helen_interp2\" width=\"231\" height=\"300\" \/><\/a><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks02.gif\"> <img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2981 alignnone\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/07\/Mt.St_.Helen_wks02-300x290.gif\" alt=\"Mt.St.Helen_wks02\" width=\"300\" height=\"290\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>3) To set the same XY data order in\u00a0Book1 and Book2, For Book1,\u00a0select\u00a0<strong>Worksheet: Sort Worksheet: Custom<\/strong> menu, choose <strong>A<\/strong> and click <strong>Ascending&gt;&gt;<\/strong> button. Then choose <strong>B<\/strong> and click <strong>Ascending&gt;&gt;<\/strong> button. This will do a nested sort. Column A will be the primary sort column and column B will be the secondary sort column. Do the same operations for Book2. Their XY arrangements are now identical.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_sort1.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2893 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_sort1.gif\" alt=\"Mt.St.Helen_sort1\" width=\"691\" height=\"218\" \/><\/a><\/p>\n<p>4) Finally, we can subtract the Book1&#8217;s Z data from Book2&#8217;s Z data. To do so, first, add a column D in Book1. Copy-and-paste the column C(Z) column in Book2 to\u00a0column <strong>D<\/strong> in Book1. Add another column E in Book1. Use\u00a0<strong>Set Column Values<\/strong> tool to calculate column E by <strong>col(D)-col(C)<\/strong>. Right click column E and set as Z.\u00a0We are now ready to make a contour plot for the difference between Book2 and Book1.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_wks3.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2895\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_wks3-300x164.gif\" alt=\"Mt.St.Helen_wks3\" width=\"300\" height=\"164\" \/><\/a><\/p>\n<p>5) Select column\u00a0E(Z), and make a contour plot. Corresponding A(X) and B(Y) will be used to create the Contour plot. You can customize as you like. You get a contour like Graph3.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following two graphs are the contour plots of Mt. &hellip; <\/p>","protected":false},"author":10,"featured_media":2889,"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":[111],"tags":[],"class_list":["post-2887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-graphing-3d-and-contour"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7DvU2-Kz","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/Mt.St_.Helen_layout.gif","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2887","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\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=2887"}],"version-history":[{"count":38,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2887\/revisions"}],"predecessor-version":[{"id":3032,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2887\/revisions\/3032"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/2889"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=2887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=2887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=2887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}