{"id":1651,"date":"2020-03-01T22:30:03","date_gmt":"2020-03-01T14:30:03","guid":{"rendered":"https:\/\/people.utm.my\/yap\/?page_id=1651"},"modified":"2021-01-17T00:15:26","modified_gmt":"2021-01-16T16:15:26","slug":"plotting-data-in-gnuplot","status":"publish","type":"page","link":"https:\/\/people.utm.my\/yap\/plotting-data-in-gnuplot\/","title":{"rendered":"Plotting Data in Gnuplot"},"content":{"rendered":"<p style=\"text-align: right\"><span style=\"font-size: 12pt\">(<a href=\"https:\/\/people.utm.my\/yap\/plotting-and-fitting-using-gnuplot\/\">Back to index page<\/a>)<\/span><\/p>\n<p><span style=\"font-size: 12pt\">Normally, you do not need to import the data into gnuplot to plot it. \u00a0<\/span><br \/>\n<span style=\"font-size: 12pt\"> Just use the plot command directly with the filename<\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-family: 'courier new', courier, monospace;font-size: 12pt\">plot &#8220;filename.dat&#8221; with line using 1:2<\/span><\/p>\n<p><span style=\"font-size: 12pt\">Explanation:<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">plot<\/span> = is the command to plot<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">&#8220;filename.dat&#8221;<\/span> = is the filename and the filetype located in the active folder<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">with line<\/span> = how will you plot your data? This command uses a line connecting the datapoints.<\/span><br \/>\n<span style=\"font-size: 12pt\"> Another option is &#8220;with point&#8221;. There are various options that you can choose but you will need to learn\/explore it. Please google yourself for more info.<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">using 1:2<\/span> = this command tells gnuplot which column in your &#8220;filename.dat&#8221; to plot your data.<\/span><br \/>\n<span style=\"font-size: 12pt\"> In this case, it is columns 1 and 2 for x and y, respectively.<\/span><\/p>\n<p><span style=\"font-size: 12pt\">If this does not work, there are several possible reasons:<\/span><\/p>\n<ol>\n<li><span style=\"font-size: 12pt\">The folder location is wrong<\/span><\/li>\n<li><span style=\"font-size: 12pt\">The filename is wrong<\/span><\/li>\n<li><span style=\"font-size: 12pt\">The selected columns are wrong<\/span><\/li>\n<li><span style=\"font-size: 12pt\">The datafile separator is different<\/span><\/li>\n<li><span style=\"font-size: 12pt\">and other reasons that I do not know yet..<\/span><\/li>\n<\/ol>\n<p style=\"text-align: right\"><span style=\"font-size: 12pt\">(<a href=\"https:\/\/people.utm.my\/yap\/plotting-and-fitting-using-gnuplot\/\">Back to index page<\/a>)<\/span><\/p>\n<p><span style=\"font-size: 12pt\">You can also perform mathematical operations on the data directly.\u00a0 For example, you want to squareroot column 2 in the data&#8230;\u00a0<\/span><span style=\"font-size: 12pt\">or maybe multiply it with 1000.. or sine it.. <em>you get the idea. <\/em><\/span><\/p>\n<p><span style=\"font-size: 12pt\">To do this, use parentheses ( ) and you can perform such operations.<em>. <\/em>For example: <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">using ($1):2 =\u00a0<\/span>the dollar sign indicates column. If you do not put $ symbol, the &#8220;1&#8221; will be the number 1 and not a constant. As you can see, there is no mathematical operation here (yet).<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">using ($1*2):2 = <\/span>multiplies column 1 with 2.<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">using ($1**4):2 = <\/span>column 1 to the power of 4.<\/span><\/p>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: 'courier new', courier, monospace\">using 1:(sqrt($2**2+$3**2)) = <\/span>square root the sum of squared data from column 2 and 3.<\/span><\/p>\n<p>You can perform all sorts of maths operation to the data..<\/p>\n<p style=\"text-align: right\"><span style=\"font-size: 12pt\">(<a href=\"https:\/\/people.utm.my\/yap\/plotting-and-fitting-using-gnuplot\/\">Back to index page<\/a>)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>(Back to index page) Normally, you do not need to import the data into gnuplot to plot it. \u00a0 Just use the plot command directly with the filename plot &#8220;filename.dat&#8221; with line using 1:2 Explanation: plot = is the command to plot &#8220;filename.dat&#8221; = is the filename and the filetype located in the active folder [&hellip;]<\/p>\n","protected":false},"author":14205,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-1651","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/pages\/1651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/users\/14205"}],"replies":[{"embeddable":true,"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/comments?post=1651"}],"version-history":[{"count":3,"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/pages\/1651\/revisions"}],"predecessor-version":[{"id":1886,"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/pages\/1651\/revisions\/1886"}],"wp:attachment":[{"href":"https:\/\/people.utm.my\/yap\/wp-json\/wp\/v2\/media?parent=1651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}