<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8684207873816623164</id><updated>2012-03-08T05:11:04.823-08:00</updated><category term='Python'/><category term='histogram'/><category term='key'/><category term='shadow'/><category term='statistic'/><category term='latex'/><category term='Chinese'/><category term='rgb color'/><category term='margin'/><category term='gnuplot binary'/><category term='broken axes'/><category term='contour plot'/><category term='gray color'/><category term='data manipulation'/><category term='I/O'/><category term='pie chart'/><category term='transparency'/><category term='gradient color'/><category term='animation'/><category term='bar chart'/><category term='blank picture'/><category term='cross axis'/><category term='script'/><category term='background'/><category term='Rectangle'/><category term='Multi-language'/><category term='image'/><category term='中文'/><category term='implicit plot'/><category term='legend'/><title type='text'>Gnuplot surprising</title><subtitle type='html'>I always tell myself: "Use your head, then you may find Gnuplot can plot graphics surprising you!"</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-3752791973497020665</id><published>2012-02-17T22:55:00.000-08:00</published><updated>2012-02-17T22:55:47.880-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cross axis'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>How to plot a cross shaped axis when using gnuplot</title><content type='html'>It is always asked by my friends that how to plot a graph with cross shaped axis when using gnuplot. To the best of my knowledge, there is not such a built in axis style in gnuplot. So you have to draw the axis manually. Here a script is provided. You can just use it. If you would like to make some improvements, It is welcomed.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#frame.gnuplot&lt;br /&gt;#Author: 数声风笛离亭晚，我想潇湘君想秦&lt;br /&gt;##########################################################&lt;br /&gt;#Utility: plot a "+" style axis&lt;br /&gt;&lt;br /&gt;#Usage:&lt;br /&gt;#call "frame.gnuplot" "ox" "oy" "xmin" "xmax" "ymin"\&lt;br /&gt;#     "ymax" "dx" "dy"&lt;br /&gt;&lt;br /&gt;#Parameters: &lt;br /&gt;#(Frame_ox,Frame_oy):     The position of the origin&lt;br /&gt;#(Frame_xmin,Frame_ymin): The bottum-left point&lt;br /&gt;#(Frame_xmax,Frame_ymax): The top-right point&lt;br /&gt;#Frame_dx:                The interval of x-ticks&lt;br /&gt;#Frame_dy:                The interval of y-ticks&lt;br /&gt;&lt;br /&gt;#Before calling this script, Frame_xtic_len and &lt;br /&gt;#Frame_ytic_len can be set to control the length&lt;br /&gt;#of the corresponding tick length. The length is &lt;br /&gt;#measured in graph coordinate. The default values &lt;br /&gt;#are 0.02 and 0.01.&lt;br /&gt;&lt;br /&gt;#Example:&lt;br /&gt;#Frame_xtic_len = 0.01&lt;br /&gt;#Frame_ytic_len = 0.01&lt;br /&gt;#call "frame.gnuplot" "0." "1.0" "-10." "10." "0." \&lt;br /&gt;#     "2." "2." "0.2"&lt;br /&gt;#plot sin(x)+1.&lt;br /&gt;##########################################################&lt;br /&gt;Frame_ox=$0&lt;br /&gt;Frame_oy=$1&lt;br /&gt;Frame_xmin=$2&lt;br /&gt;Frame_xmax=$3&lt;br /&gt;Frame_ymin=$4&lt;br /&gt;Frame_ymax=$5&lt;br /&gt;Frame_dx=$6&lt;br /&gt;Frame_dy=$7&lt;br /&gt;&lt;br /&gt;#set the default value of Frame_x(y)tic_len&lt;br /&gt;if (!exist("Frame_xtic_len")) Frame_xtic_len=0.02&lt;br /&gt;if (!exist("Frame_ytic_len")) Frame_ytic_len=0.01&lt;br /&gt;#no plot of the default border and tics&lt;br /&gt;set border 0&lt;br /&gt;unset tics&lt;br /&gt;#set the xrange and yrange to the user defined value&lt;br /&gt;set xrange [Frame_xmin:Frame_xmax]&lt;br /&gt;set yrange [Frame_ymin:Frame_ymax]&lt;br /&gt;#draw the axis&lt;br /&gt;set arrow from graph 0, first Frame_oy to graph 1.03,\&lt;br /&gt;    first Frame_oy size graph 0.02,15,60 fill ls -1&lt;br /&gt;set arrow from first Frame_ox, graph 0 to first Frame_ox,\&lt;br /&gt;    graph 1.03 size graph 0.015,15,60 fill ls -1&lt;br /&gt;#draw the ticks&lt;br /&gt;set for [i=0:int((Frame_xmax-Frame_xmin)/Frame_dx)] \&lt;br /&gt;    arrow from Frame_xmin+i*Frame_dx,Frame_oy to \&lt;br /&gt;    Frame_xmin+i*Frame_dx,Frame_oy+ \&lt;br /&gt;    (Frame_ymax - Frame_ymin)*Frame_xtic_len nohead&lt;br /&gt;set for [i=0:int((Frame_ymax-Frame_ymin)/Frame_dy)] \&lt;br /&gt;    arrow from Frame_ox,Frame_ymin+i*Frame_dy to \&lt;br /&gt;    Frame_ox+(Frame_xmax - Frame_xmin)*Frame_ytic_len, \&lt;br /&gt;    Frame_ymin+i*Frame_dy nohead&lt;br /&gt;#draw the labels with the ticks&lt;br /&gt;set for [i=0:int((Frame_xmax-Frame_xmin)/Frame_dx)] \&lt;br /&gt;    label sprintf("%3.1f",Frame_xmin+i*Frame_dx) at \&lt;br /&gt;    Frame_xmin+i*Frame_dx,Frame_oy center offset 0,-0.75&lt;br /&gt;set for [i=0:int((Frame_ymax-Frame_ymin)/Frame_dy)] \&lt;br /&gt;    label sprintf("%3.1f",Frame_ymin+i*Frame_dy) at \&lt;br /&gt;    Frame_ox,Frame_ymin+i*Frame_dy right offset -0.75,0&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Now let us show how this script is used by an example.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;Frame_xtic_len = 0.01&lt;br /&gt;Frame_ytic_len = 0.01&lt;br /&gt;call "frame.gnuplot" "0." "1.0" "-10." "10." "0." \&lt;br /&gt;     "2." "2." "0.2"&lt;br /&gt;plot sin(x)+1. notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-IGQjaQioeWw/Tz9KwtWz5AI/AAAAAAAAATQ/GCUkT3zs4B8/s1600/cross_style_axis.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="182" src="http://4.bp.blogspot.com/-IGQjaQioeWw/Tz9KwtWz5AI/AAAAAAAAATQ/GCUkT3zs4B8/s320/cross_style_axis.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Fig.1 Cross shaped axis plotted by gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-3752791973497020665?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/3752791973497020665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2012/02/how-to-plot-cross-shaped-axis-when.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3752791973497020665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3752791973497020665'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2012/02/how-to-plot-cross-shaped-axis-when.html' title='How to plot a cross shaped axis when using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-IGQjaQioeWw/Tz9KwtWz5AI/AAAAAAAAATQ/GCUkT3zs4B8/s72-c/cross_style_axis.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6001854035266320346</id><published>2012-01-09T04:00:00.001-08:00</published><updated>2012-01-09T04:00:40.446-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='中文'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>gnuplot的多国语言支持----通过latex（2）</title><content type='html'>上一个帖子中我们介绍了通过latex实现gnuplot的多国语言支持。但是该方法有些繁琐——需要两步才能得到最后的图像。在实际应用的时候该方法可以通过(*)latex终端类型的“header”参数来简化。若将latex宏包调用以及其他一些命令放到该参数后面则生成的tex文件将在文件头部分包含这些信息。这样就不需要手动修改tex文件了，一步就可以得到最后的图像。&lt;br /&gt;&lt;br /&gt;试一试下面的脚步。运行之，然后用latex编译生成的tex文件，编译生成的文件已经中文支持。&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term epslatex color standalone header \&lt;br /&gt;"\\usepackage{CJK}\n \&lt;br /&gt;\\AtBeginDocument{\\begin{CJK*}{GBK}{song}} \&lt;br /&gt;\\AtEndDocument{\\end{CJK*}}"&lt;br /&gt;&lt;br /&gt;set output "voltage.tex"&lt;br /&gt;&lt;br /&gt;set xlabel "时间（秒）"&lt;br /&gt;set ylabel "电压（伏）"&lt;br /&gt;unset key&lt;br /&gt;plot sin(x)+0.1*(2*rand(0)-1.) w l lw 2&lt;br /&gt;set output &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s1600/voltage_chinese.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s320/voltage_chinese.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;gnuplot绘制的支持中文的图像&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6001854035266320346?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6001854035266320346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2012/01/gnuplot-latex2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6001854035266320346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6001854035266320346'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2012/01/gnuplot-latex2.html' title='gnuplot的多国语言支持----通过latex（2）'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s72-c/voltage_chinese.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-2992987651695903864</id><published>2011-12-22T02:17:00.000-08:00</published><updated>2011-12-22T02:17:52.059-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='中文'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='Multi-language'/><category scheme='http://www.blogger.com/atom/ns#' term='Chinese'/><title type='text'>Multi-language support of gnuplot  --- Using latex (2)</title><content type='html'>We have shown how to get multi-language support by using latex in the former posts. It works, but a little complicated --- You need to take two steps to get the final graph. In practice, it can be simplified by using an option of the (*)latex terminal. This option is "header". You can put the package use and other commands after this option, and then the generated tex file will contain these information at the header part. So you need not to modify the tex file manually. You get the final graph at one step.&lt;br /&gt;&lt;br /&gt;So try the following plot script. Run it and compile the output tex file using latex, and at once you a Chinese supported graph.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term epslatex color standalone header \&lt;br /&gt;"\\usepackage{CJK}\n \&lt;br /&gt;\\AtBeginDocument{\\begin{CJK*}{GBK}{song}} \&lt;br /&gt;\\AtEndDocument{\\end{CJK*}}"&lt;br /&gt;&lt;br /&gt;set output "voltage.tex"&lt;br /&gt;&lt;br /&gt;set xlabel "时间（秒）"&lt;br /&gt;set ylabel "电压（伏）"&lt;br /&gt;unset key&lt;br /&gt;plot sin(x)+0.1*(2*rand(0)-1.) w l lw 2&lt;br /&gt;set output &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s1600/voltage_chinese.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s320/voltage_chinese.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gnuplot plotted graph with Chinese support&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-2992987651695903864?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/2992987651695903864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/multi-language-support-of-gnuplot-using_22.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2992987651695903864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2992987651695903864'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/multi-language-support-of-gnuplot-using_22.html' title='Multi-language support of gnuplot  --- Using latex (2)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s72-c/voltage_chinese.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-8621019588410867009</id><published>2011-12-15T03:53:00.000-08:00</published><updated>2012-01-09T04:01:55.268-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='中文'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>gnuplot的多国语言支持----通过latex（1）</title><content type='html'>非英语用户经常遇到的一个问题就是在图像中插入非英语字符。对新手而言，有时这是一件很具挑战性的工作。该帖子将讨论如何使用latex来解决该问题。&lt;br /&gt;&lt;br /&gt;我们知道通过使用合适的宏包latex可以进行多语言排版。我们还知道gnuplot的终端类型中包括诸如latex，epslatex等。所以我们可以先在这些终端类型下绘图，然后通过修改tex文件来获得图像的多国语言支持。下面以中文的支持为例来说明该问题。&lt;br /&gt;&lt;br /&gt;首先我们使用下面的脚本来绘图。&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term epslatex color standalone&lt;br /&gt;set output "voltage.tex"&lt;br /&gt;set xlabel "my xlabel"&lt;br /&gt;set ylabel "my ylabel"&lt;br /&gt;unset key&lt;br /&gt;plot sin(x)+0.1*(2*rand(0)-1.) w l lw 2&lt;br /&gt;set output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;使用latex编译输出的tex文件，得到如下图片&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s1600/voltage.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s320/voltage.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;无中文支持的gnuplot绘图结果&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;我们希望将x轴标注为“时间（秒）”，y轴标注为“电压（伏）”。为实现该效果，使用任意文本编辑软件打开tex文件，找到如下行&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\put(4039,154){\makebox(0,0){\strut{}my xlabel}}%&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;和&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\put(308,2739){\rotatebox{-270}{\makebox(0,0){\strut{}my ylabel}}}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;然后将“my xlabel”替换为“时间（秒）”，将“my ylabel”替换为“电压（伏）”。同时将下面的代码加到文件的头部分来得到latex对中文的支持。&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\usepackage{CJK}&lt;br /&gt;\AtBeginDocument{\begin{CJK*}{GBK}{song}}&lt;br /&gt;\AtEndDocument{\end{CJK*}}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;此时再次编译tex文件就可以得到中文支持的的图片了。&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s1600/voltage_chinese.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s320/voltage_chinese.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;中文支持的gnuplot绘图结果&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;修改前和修改后的tex可以通过下面链接下载。&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.google.com/open?id=0B5wSAiwiTq4gOTViYzViMGMtN2MzZi00NTc5LTgzNjMtZjc4ZDMwYjM2OWI4" target="_blank"&gt;voltage.tex&lt;/a&gt;&amp;nbsp; &lt;a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNGY5ZTU1MDUtNGI4OS00YWM0LThhNWItMGRlMTM3NTM0N2Fi" target="_blank"&gt;voltage_chinese.tex&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-8621019588410867009?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/8621019588410867009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/gnuplot-latex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8621019588410867009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8621019588410867009'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/gnuplot-latex.html' title='gnuplot的多国语言支持----通过latex（1）'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s72-c/voltage.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-3619542607676556172</id><published>2011-12-03T23:42:00.001-08:00</published><updated>2012-01-09T04:01:05.423-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='中文'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='Multi-language'/><category scheme='http://www.blogger.com/atom/ns#' term='Chinese'/><title type='text'>Multi-language support of gnuplot  --- Using latex</title><content type='html'>For some non-English speakers, inserting some their own characters into the graph is usual. And for some fresh, this some times becomes a challenging task. This posts will talk about how to solve this problem using latex.&lt;br /&gt;&lt;br /&gt;We know that some packages used latex can deal with multi-language typesetting. And we also know that gnuplot have terminals like latex, epslatex. So we can first plot a English graph with these terminals, then modify the output tex files, and at last get a multi-language supported graph. Take Chinese support for example.&lt;br /&gt;&lt;br /&gt;We first plot a graph using the following script.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term epslatex color standalone&lt;br /&gt;set output "voltage.tex"&lt;br /&gt;set xlabel "my xlabel"&lt;br /&gt;set ylabel "my ylabel"&lt;br /&gt;unset key&lt;br /&gt;plot sin(x)+0.1*(2*rand(0)-1.) w l lw 2&lt;br /&gt;set output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Compile the output tex file using latex we get a graph like the following one.&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s1600/voltage.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s320/voltage.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gnuplot plotted graph without Chinese support&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;And we want to label the x-axes with "时间（秒）"(means time) and y-axes with "电压（伏）"(means voltage). To realize this effect, we open the tex file with any text editor and find lines&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\put(4039,154){\makebox(0,0){\strut{}my xlabel}}%&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\put(308,2739){\rotatebox{-270}{\makebox(0,0){\strut{}my ylabel}}}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Then we repalce "my xlabel" with "时间（秒）", "my ylabel" with "电压（伏）". And add the following codes into the header part of the file to get the chinese support of latex.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;\usepackage{CJK}&lt;br /&gt;\AtBeginDocument{\begin{CJK*}{GBK}{song}}&lt;br /&gt;\AtEndDocument{\end{CJK*}}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;This time compile the tex file uising latex again. And a chinese supported graph is gotten.&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s1600/voltage_chinese.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="http://1.bp.blogspot.com/-jlZBgMYj_h0/TtsmbfkACtI/AAAAAAAAAOI/x8aQSNpHvKA/s320/voltage_chinese.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gnuplot plotted graph with Chinese support&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The modified and pre-modified tex files can be downloaded here.&lt;br /&gt;&lt;a href="https://docs.google.com/open?id=0B5wSAiwiTq4gOTViYzViMGMtN2MzZi00NTc5LTgzNjMtZjc4ZDMwYjM2OWI4" target="_blank"&gt;voltage.tex&lt;/a&gt;&amp;nbsp; &lt;a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNGY5ZTU1MDUtNGI4OS00YWM0LThhNWItMGRlMTM3NTM0N2Fi" target="_blank"&gt;voltage_chinese.tex&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-3619542607676556172?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/3619542607676556172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/multi-language-support-of-gnuplot-using.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3619542607676556172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3619542607676556172'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/12/multi-language-support-of-gnuplot-using.html' title='Multi-language support of gnuplot  --- Using latex'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-bwjRDmrycyY/TtslJeBQ7CI/AAAAAAAAAN8/gv8eHthJoXc/s72-c/voltage.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-2468547492919886366</id><published>2011-11-22T02:21:00.001-08:00</published><updated>2011-11-22T02:25:25.467-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='blank picture'/><title type='text'>How to plot nothing using gnuplot</title><content type='html'>Some times we just want to create a figure with only the axes ticks and so on, no any content (The content may be added later use some other tools). We know that if there is not a plot command, gnuplot will not create a output picture, So play some tricks should be played. In this post I will talk on two methods to plot nothing using gnuplot.&lt;br /&gt;&lt;br /&gt;The first one is plot a line with background color.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png font ",20" xffffff  #set png terminal and the background color is white&lt;br /&gt;set output "blank.png"&lt;br /&gt;set key off&lt;br /&gt;set ytics 0.5&lt;br /&gt;plot sin(x) with line linecolor rgb"#ffffff"&lt;br /&gt;set output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The second one is plot something out of yrange.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;set term png font ",20"&lt;br /&gt;set output "blank.png"&lt;br /&gt;set yrange [-1:1]&lt;br /&gt;set key off&lt;br /&gt;plot 2 with lines&lt;br /&gt;set output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Maybe some other methods also exist, But this three shold be the most used and simplest ones. At last a sample picture posted. (The two methods will just creat pictures the simillar as this one.)&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-hGs6X25y7Yo/Tst4L4_R5NI/AAAAAAAAAMQ/1The0BueqjI/s1600/blank.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-hGs6X25y7Yo/Tst4L4_R5NI/AAAAAAAAAMQ/1The0BueqjI/s320/blank.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Plot nothing using gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-2468547492919886366?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/2468547492919886366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/11/how-to-plot-nothing-using-gnuplot.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2468547492919886366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2468547492919886366'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/11/how-to-plot-nothing-using-gnuplot.html' title='How to plot nothing using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-hGs6X25y7Yo/Tst4L4_R5NI/AAAAAAAAAMQ/1The0BueqjI/s72-c/blank.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-1631468858388836319</id><published>2011-11-15T03:18:00.001-08:00</published><updated>2011-11-15T03:51:43.828-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='margin'/><title type='text'>Aviodding the blank margin of a eps picture being auto croped by some softwares</title><content type='html'>Some one complained to me that when he inserted a gnuplot produced eps picture into some software (not all) the blank margins are auto cropped. And he want to avoid this to happen.&lt;br /&gt;Yes, I also found this problem myself. Some software "intelligently" crop the blank margin of a postscript picture. Always this is just OK. But in some special cases, we set a blank margin of special purpose, for example, to leave some spaces for readers to add some notes. In these cases, the "intelligence" becomes "stupid".&lt;br /&gt;I solve this problem by adding a invisible rectangle (with linewidth equals 0 or with color same as the background color and fillstyle onborder) as large as the screen, i.e.,&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;set object rectangle from screen 0,0 to screen 1,1 \&lt;br /&gt;    lw 0 fillstyle noborder behind   &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Then although there are blank margins but they are not blank in fact. So when the picture is inserted to other software, the margin will not be auto cropped.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-1631468858388836319?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/1631468858388836319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/11/aviodding-blank-margin-of-eps-picture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1631468858388836319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1631468858388836319'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/11/aviodding-blank-margin-of-eps-picture.html' title='Aviodding the blank margin of a eps picture being auto croped by some softwares'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-7226025672921216677</id><published>2011-10-30T04:01:00.000-07:00</published><updated>2011-10-30T04:02:27.549-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bar chart'/><category scheme='http://www.blogger.com/atom/ns#' term='histogram'/><title type='text'>Add value labels to the top of bars in a bar chart</title><content type='html'>It is easy to plot a bar chart with gnuplot using plot style boxes or histogram. This time we talk about how to add values labels to the top of bars in a bar chart.&lt;br /&gt;&lt;br /&gt;The first coming idea is adding labels manually using command "set label ...". This a method but a poor efficient one. A better one is plot the labels with plot style "labels". And this is the method we will talk about here. A sample script is shown below.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png font "Times,18"    #set terminal and output file&lt;br /&gt;set output "bar_labels.png"&lt;br /&gt;set xlabel "x value"    #set x and y label&lt;br /&gt;set ylabel "Frequency"&lt;br /&gt;set xrange [-0.5:4.5]    #set x and y range&lt;br /&gt;set yrange [0:4]&lt;br /&gt;set xtics 0,1,4    #set xtics&lt;br /&gt;set style fill solid    #set plot style&lt;br /&gt;set boxwidth 0.5&lt;br /&gt;unset key    #legend not plotted&lt;br /&gt;plot "bar_data.dat" using 1:2 with boxes,\&lt;br /&gt;     "bar_data.dat" using 1:2:2 with labels&lt;br /&gt;#plot bar chart and the value labels on the bars&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In this script, we have used a data file (bar_data.dat) like this one&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;0    2&lt;br /&gt;1    3&lt;br /&gt;2    3&lt;br /&gt;3    2&lt;br /&gt;4    2&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Run the script, we get picture file bar_labels.png like the following one.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-bkdkFiCEgqQ/Tq0tIymnfCI/AAAAAAAAALU/ZleUR4nodn4/s1600/bar_labels.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-bkdkFiCEgqQ/Tq0tIymnfCI/AAAAAAAAALU/ZleUR4nodn4/s320/bar_labels.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gnuplot bar chart with value labels&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;If you do not like the position of the labels in the upper picture, you can just change it. For example,&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;lot "bar_data.dat" using 1:2 with boxes,\&lt;br /&gt;     "bar_data.dat" using 1:($2+0.25):2 with labels&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;will put the labels 0.25 units higher.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-mNAISvxLh1g/Tq0uJr5aCOI/AAAAAAAAALg/SgF32sn9USg/s1600/bar_labels.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-mNAISvxLh1g/Tq0uJr5aCOI/AAAAAAAAALg/SgF32sn9USg/s320/bar_labels.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Value labels with a 0.25 units higher position&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-7226025672921216677?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/7226025672921216677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/add-value-labels-to-top-of-bars-in-bar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7226025672921216677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7226025672921216677'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/add-value-labels-to-top-of-bars-in-bar.html' title='Add value labels to the top of bars in a bar chart'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-bkdkFiCEgqQ/Tq0tIymnfCI/AAAAAAAAALU/ZleUR4nodn4/s72-c/bar_labels.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-3628737339843071492</id><published>2011-10-19T05:35:00.000-07:00</published><updated>2011-10-19T05:37:13.565-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='broken axes'/><title type='text'>Broken axes graph in gnuplot (3)</title><content type='html'>To plot a x-axes broken graph with datafile, the two methods described in the last two posts are also suitable. The first method can be applied straightforwardly. And now we come to an example to apply the second method to a datafile plotting.&lt;br /&gt;&lt;br /&gt;Consider such a case, an experiment team research on a material's thermodynamical properties. They heat it and record the temperature for 13 hours the first day, then its time for they to go home. And they go on their recording the second day. At last they get a data file like the following one.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;0.00    25.76 &lt;br /&gt;1.00   29.91 &lt;br /&gt;2.00   35.33 &lt;br /&gt;3.00   38.85 &lt;br /&gt;4.00   43.15 &lt;br /&gt;5.00   47.35 &lt;br /&gt;6.00   50.45 &lt;br /&gt;7.00   53.55 &lt;br /&gt;8.00   56.12 &lt;br /&gt;9.00   57.31 &lt;br /&gt;10.00  59.11 &lt;br /&gt;11.00  62.21 &lt;br /&gt;12.00  62.17 &lt;br /&gt;13.00  63.05 &lt;br /&gt;&lt;br /&gt;23.00  63.56 &lt;br /&gt;24.00  62.98 &lt;br /&gt;25.00  66.05 &lt;br /&gt;26.00  65.88 &lt;br /&gt;27.00  64.70 &lt;br /&gt;28.00  65.37 &lt;br /&gt;29.00  63.12 &lt;br /&gt;30.00  65.66 &lt;br /&gt;31.00  66.14 &lt;br /&gt;32.00  64.92 &lt;br /&gt;33.00  65.68 &lt;br /&gt;34.00  64.01 &lt;br /&gt;35.00  63.50&lt;br /&gt;36.00   63.75&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;We can find that their is a break when they go home. We will use a broken axes graph to deal with this break. &lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;set term post eps enhanced&lt;br /&gt;set output "broken_axes3.png"&lt;br /&gt;set xrange [0:36-10+0.5]&lt;br /&gt;set yrange [25:70]&lt;br /&gt;set border 2+8&lt;br /&gt;set arrow 1 from 0,25 to 13,25 nohead&lt;br /&gt;set arrow 2 from 13.5,25 to 26.5,25 nohead&lt;br /&gt;set arrow 3 from 0,70 to 13,70 nohead&lt;br /&gt;set arrow 4 from 13.5,70 to 26.5,70 nohead&lt;br /&gt;&lt;br /&gt;set arrow 5 from 12.75,24 to 13.25,26 nohead&lt;br /&gt;set arrow 6 from 13.25,24 to 13.75,26 nohead&lt;br /&gt;set arrow 7 from 12.75,69 to 13.25,71 nohead&lt;br /&gt;set arrow 8 from 13.25,69 to 13.75,71 nohead&lt;br /&gt;&lt;br /&gt;set xtics ("0" 0, "4" 4, "8" 8, "12" 12,\&lt;br /&gt;           "24" 14.5, "28" 18.5, "32" 22.5, "36" 26.5)&lt;br /&gt;set xlabel "Time:t(h)"&lt;br /&gt;set ylabel "Temperature:T({/Symbol \260}C)"&lt;br /&gt;plot "data.dat" u ($1&amp;lt;13. ?$1: $1&amp;gt;13. ?($1-9.5):1/0):2 w lp lw 2 ps 2 notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In this script the key point is "u ($1&amp;lt;13 ?$1: $1&amp;gt;13 ?($1-9.5):1/0):2" which transform range [23:36] to range [13.5:26.5] and let range [0:13] uneffected. The followng piture is broken_axes3.png (This png file is converted from broken_axes.eps).&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-x4IMP7t4bGk/Tp7DxIgDRhI/AAAAAAAAALA/LE3ryQHTOIM/s1600/broken_axes3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="228" src="http://2.bp.blogspot.com/-x4IMP7t4bGk/Tp7DxIgDRhI/AAAAAAAAALA/LE3ryQHTOIM/s320/broken_axes3.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Broken x-axes graph plotted using gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-3628737339843071492?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/3628737339843071492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3628737339843071492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3628737339843071492'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot-3.html' title='Broken axes graph in gnuplot (3)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-x4IMP7t4bGk/Tp7DxIgDRhI/AAAAAAAAALA/LE3ryQHTOIM/s72-c/broken_axes3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-1871822476779314197</id><published>2011-10-16T06:01:00.000-07:00</published><updated>2011-10-16T06:01:10.930-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='broken axes'/><title type='text'>Broken axes graph in gnuplot (2)</title><content type='html'>Last time I said there is a "better but a little tricky" method to plot a broken axes graph. And now let us come to see this method.&lt;br /&gt;&lt;br /&gt;If we want to plot function f(x) in range of [a:b] and [c:d] (i.e., a broken axes graph), we can define a new function:&lt;br /&gt;&lt;pre&gt;g(x) = f(x)                         a&amp;lt;= x &amp;lt;= b&lt;br /&gt;g(x) = f(x+c-b-dx)              b+dx &amp;lt;= x &amp;lt;= b+dx-c+d&lt;br /&gt;g(x) = 1/0                         other x&lt;br /&gt;&lt;/pre&gt;where dx is the gap length. We plot this new function and modify xtics to a right one. Then we get a broken x-axes graph  which will similar to the one we plotted last time. Let us start work our idea out.  &lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "broken_axes2.png"&lt;br /&gt;#Plot f(x)=sin(x**2/4.) at range [20:22] and [40:42]&lt;br /&gt;f(x)=sin(x**2/4.)&lt;br /&gt;g(x)=20&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;22 ?f(x) :22&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;22.2 ?1/0 :22.2&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;24.2 ?f(x+17.8) :1/0&lt;br /&gt;set xrange [20:24.2]&lt;br /&gt;set yrange [-1:1]&lt;br /&gt;set sample 2000&lt;br /&gt;set border 2+8  #the bottom and top border will be plotted mannually&lt;br /&gt;set arrow 1 from 20,-1 to 22,-1 nohead              #bottom and top border&lt;br /&gt;set arrow 2 from 22.2,-1 to 24.2,-1 nohead&lt;br /&gt;set arrow 3 from 20,1 to 22,1 nohead&lt;br /&gt;set arrow 4 from 22.2,1 to 24.2,1 nohead&lt;br /&gt;set arrow 5 from 21.95,-1.05 to 22.05,-0.95 nohead  #axes broken indication line&lt;br /&gt;set arrow 6 from 22.15,-1.05 to 22.25,-0.95 nohead&lt;br /&gt;set arrow 7 from 21.95,0.95 to 22.05,1.05 nohead&lt;br /&gt;set arrow 8 from 22.15,0.95 to 22.25,1.05 nohead&lt;br /&gt;#Modify xtics to a right value&lt;br /&gt;set xtics ("20" 20,"20.5" 20.5,"21" 21,"21.5" 21.5,"22" 22,\&lt;br /&gt;           "40" 22.2,"40.5" 22.7,"41" 23.2,"41.5" 23.7,"42"24.2)&lt;br /&gt;set xlabel "Time:t(s)"&lt;br /&gt;set ylabel "Signal:U(V)"&lt;br /&gt;plot g(x) w l lw 2 notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The picture file broken_axes2.png is shown below.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-1Je5C3b_fxs/TprUN52sljI/AAAAAAAAAK4/RNmluaiPitk/s1600/broken_axes2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-1Je5C3b_fxs/TprUN52sljI/AAAAAAAAAK4/RNmluaiPitk/s320/broken_axes2.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Broken axes graph plotted by gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Next time I will put this method to the datafile case.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-1871822476779314197?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/1871822476779314197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1871822476779314197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1871822476779314197'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot-2.html' title='Broken axes graph in gnuplot (2)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-1Je5C3b_fxs/TprUN52sljI/AAAAAAAAAK4/RNmluaiPitk/s72-c/broken_axes2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-5424564993370601507</id><published>2011-10-06T05:19:00.000-07:00</published><updated>2011-10-17T06:51:50.451-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='broken axes'/><title type='text'>Broken axes graph in gnuplot (1)</title><content type='html'>If the range of data is large, it is not &lt;span style="color: black; font-size: 10.5pt; line-height: normal;"&gt;convenient&lt;/span&gt; to plot the whole range. Then broken axes graph is introduced. Let us see a broken axes graph at first and then how it is plotted.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-wcjfT811His/To2bEUatZJI/AAAAAAAAAKo/UOPnKQOiSrc/s1600/broken_axes1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-wcjfT811His/To2bEUatZJI/AAAAAAAAAKo/UOPnKQOiSrc/s320/broken_axes1.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To plot a broken axes graph like the upper one, there are two methods. We first introduce the one which is simple to understand and a better but a little tricky one will be talked next time. This method uses the "multiplot" mode, plotting the left and right part of the broken axes graph separately. Let us come to see our script. This script just produce the former graph. The explaination of the script is covered as comments of the script and will not be given separately.&lt;br /&gt;&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png font "Times,15"&lt;br /&gt;set output "broken_axes1.png"&lt;br /&gt;f(x)=exp(-x)*sin(500*x)     #plotting function&lt;br /&gt;set yrange [-1:1]    #The later two plot have same yrange&lt;br /&gt;set sample 400&lt;br /&gt;set tics nomirror&lt;br /&gt;set tmargin at screen 0.9   #the later two plots will share this tmargin&lt;br /&gt;set bmargin at screen 0.1   #------------------------------------b------&lt;br /&gt;&lt;br /&gt;set multiplot    #begin multiplot mode&lt;br /&gt;&lt;br /&gt;#axes broken line&lt;br /&gt;set arrow 1  from screen 0.5,0.08 to screen 0.52,0.12 nohead&lt;br /&gt;set arrow 2  from screen 0.52,0.08 to screen 0.54,0.12 nohead&lt;br /&gt;set arrow 3  from screen 0.5,0.88 to screen 0.52,0.92 nohead&lt;br /&gt;set arrow 4  from screen 0.52,0.88 to screen 0.54,0.92 nohead&lt;br /&gt;&lt;br /&gt;#x,y axis label and title label&lt;br /&gt;set label 1 "Time: t(s)" at screen 0.475,0.025&lt;br /&gt;set label 2 "Signal:U(mV)" at screen 0.025,0.44 rotate by 90&lt;br /&gt;set label 3 center "U=exp(-t)sin(500t)" at screen 0.5,0.95&lt;br /&gt;&lt;br /&gt;#The left part&lt;br /&gt;set border 1+2+4    #the right border is not plotted&lt;br /&gt;set lmargin at screen 0.1   #the left-part's location&lt;br /&gt;set rmargin at screen 0.51&lt;br /&gt;set xtics 0,0.02,0.08&lt;br /&gt;plot [0:0.1] f(x) w l lt 1 lw 2 notitle&lt;br /&gt;&lt;br /&gt;#unset the labels and arrows, otherwise they will be plot &lt;br /&gt;#for the second time&lt;br /&gt;unset label 1&lt;br /&gt;unset label 2&lt;br /&gt;unset label 3 &lt;br /&gt;&lt;br /&gt;unset arrow 1&lt;br /&gt;unset arrow 2&lt;br /&gt;unset arrow 3&lt;br /&gt;unset arrow 4&lt;br /&gt;&lt;br /&gt;#the right part&lt;br /&gt;set border 1+4+8    #the left border is not plotted&lt;br /&gt;set lmargin at screen 0.53      #the right-part's location&lt;br /&gt;set rmargin at screen 0.94&lt;br /&gt;#ytics is not plotted, as the second plot will share it with the first one&lt;br /&gt;unset ytics&lt;br /&gt;set xtics 0.9,0.02,1.0&lt;br /&gt;plot [0.9:1] f(x) w l lt 1 lw 2&lt;br /&gt;&lt;br /&gt;unset multiplot&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-5424564993370601507?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/5424564993370601507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5424564993370601507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5424564993370601507'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/broken-axes-graph-in-gnuplot.html' title='Broken axes graph in gnuplot (1)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-wcjfT811His/To2bEUatZJI/AAAAAAAAAKo/UOPnKQOiSrc/s72-c/broken_axes1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6498692149852544011</id><published>2011-10-03T07:36:00.000-07:00</published><updated>2012-02-17T22:56:39.395-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='legend'/><category scheme='http://www.blogger.com/atom/ns#' term='key'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Round corner key box in gnuplot</title><content type='html'>In a &lt;a href="http://gnuplot-surprising.blogspot.com/2011/10/round-corner-rectangle-in-gnuplot.html"&gt;previous post&lt;/a&gt; I talked about create a round corner rectangle in gnuplot. But none application was involved in that post. Today I use the method to create a round corner key box.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;###############################################&lt;br /&gt;#Variables:&lt;br /&gt;##(a,b) is the low left vertex of the rectangle&lt;br /&gt;##(c,d) is the up right vertex of the rectangle&lt;br /&gt;##rx is the radius along x-axis&lt;br /&gt;##ry is the radius along y-axis&lt;br /&gt;##x is the independent variable of the curve&lt;br /&gt;f_low(a,b,c,d,rx,ry,x)=a&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;a+rx ? \&lt;br /&gt;     -ry*sqrt(1-((x-a-rx)/rx)**2)+b+ry : \&lt;br /&gt;     a+rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c-rx ? b :c-rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c ?\&lt;br /&gt;     -ry*sqrt(1-((x-c+rx)/rx)**2)+b+ry : 1/0&lt;br /&gt;#The low curve of a round corner rectangle&lt;br /&gt;f_up(a,b,c,d,rx,ry,x)=a&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;a+rx ?\&lt;br /&gt;     ry*sqrt(1-((x-a-rx)/rx)**2)+d-ry : \&lt;br /&gt;     a+rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c-rx ? d :c-rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c ?\&lt;br /&gt;     ry*sqrt(1-((x-c+rx)/rx)**2)+d-ry : 1/0&lt;br /&gt;#The up curve of a round corner rectangle&lt;br /&gt;###############################################&lt;br /&gt;reset&lt;br /&gt;set term png font "Times,18"    #terminal and output file&lt;br /&gt;set output "round_corner_rectangle_key_box.png"&lt;br /&gt;set tics out nomirror&lt;br /&gt;unset key    #key will be created manually&lt;br /&gt;set sample 1000    #samples&lt;br /&gt;#Setting the back ground color&lt;br /&gt;set object 1 rect from graph 0,0 to graph 1,1 back&lt;br /&gt;set object 1 rect fc rgb "#AAAAFF" fillstyle solid 1.0&lt;br /&gt;#The text of the key (some people call it legend)&lt;br /&gt;set label center "y=f(x)" at 5.75,0.7 front&lt;br /&gt;#x and y label&lt;br /&gt;set xlabel "x"&lt;br /&gt;set ylabel "y=f(x)"&lt;br /&gt;#Plot the curve,round corner rectangle and sample line of key&lt;br /&gt;plot sin(5.*x)*exp(-x*x/20.) w l lw 2 lc rgb"green",\&lt;br /&gt;     '+' u 1:(f_low(3.5,0.5,9,0.9,0.5,0.05,$1)):\&lt;br /&gt;     (f_up(3.5,0.5,9,0.9,0.5,0.05,$1)) w filledcurve\&lt;br /&gt;     lc rgb"pink" notitle,\&lt;br /&gt;     x&amp;gt;7.5 &amp;amp;&amp;amp; x&amp;lt;8.5 ?0.7:1/0 w l lw 2 lc rgb"green"&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Nothing new in this script. The only important and difficult thing is deciding the position of the key text, key sample line and key box. At last we get a picture like this one.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-JD9nB-gN1fo/TonIGGXjoTI/AAAAAAAAAKk/mjHPbuWMi6M/s1600/round_corner_rectangle_key_box.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-JD9nB-gN1fo/TonIGGXjoTI/AAAAAAAAAKk/mjHPbuWMi6M/s320/round_corner_rectangle_key_box.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Round corner key box in gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6498692149852544011?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6498692149852544011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/round-corner-key-box-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6498692149852544011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6498692149852544011'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/round-corner-key-box-in-gnuplot.html' title='Round corner key box in gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-JD9nB-gN1fo/TonIGGXjoTI/AAAAAAAAAKk/mjHPbuWMi6M/s72-c/round_corner_rectangle_key_box.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-2332954042321374975</id><published>2011-10-02T06:08:00.000-07:00</published><updated>2011-10-07T01:35:11.101-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pie chart'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Pie chart in gnuplot</title><content type='html'>Although it is advised that use pie chart as less as possible. Some times a pie chart can clearly show the percentage of some component and it is useful. So I will talk about how to make a pie chart in gnuplot.&lt;br /&gt;&lt;br /&gt; There is no command to create a pie chart in gnuplot. To plot a pie chart we need to play some tricks.&lt;br /&gt;&lt;br /&gt;A pie chart is made up of some sectors with different colors. First we come to see how to plot a sector.&lt;br /&gt;&lt;br /&gt;Sectors are parts of a sphere symmetrical plane, so it easy to plot a sector in parametric mode using splot command. For example, commands&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;set term png&lt;br /&gt;set output "sector.png"&lt;br /&gt;set parametric&lt;br /&gt;set urange [0:pi/3]&lt;br /&gt;set vrange [0:1]&lt;br /&gt;set view map&lt;br /&gt;set size square&lt;br /&gt;unset border&lt;br /&gt;unset tics&lt;br /&gt;unset colorbox&lt;br /&gt;splot cos(u)*v,sin(u)*v,1 w pm3d notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;create a sector like follows.&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-cpTH0oydK-g/Tohfjz79pWI/AAAAAAAAAKc/N1Wkckoanh4/s1600/sector.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-cpTH0oydK-g/Tohfjz79pWI/AAAAAAAAAKc/N1Wkckoanh4/s320/sector.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Sector plotted using gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Since we have solved the problem of drawing a sector, now we come to make some sectors to form a pie chart. The following is a file describing the income percentage in diffrent country of a company, we would like to plot it to a pie chart.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;England    0.2&lt;br /&gt;France    0.1&lt;br /&gt;Canada    0.3&lt;br /&gt;America    0.2&lt;br /&gt;Japan    0.1&lt;br /&gt;China    0.1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The begining and ending angles of a sector is controled by the urange, but it is not convinient to set the urange dynamically in gnuplot. So we will use python to do some assistant work. Our python script is shown below.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;import os&lt;br /&gt;import math&lt;br /&gt;&lt;br /&gt;def sign(x):&lt;br /&gt;  '''&lt;br /&gt;  Sign function.&lt;br /&gt;  sign(x)=1 when x &amp;gt;=0&lt;br /&gt;  sign(x)=1 when else.&lt;br /&gt;  '''&lt;br /&gt;  if (x&amp;gt;=0):&lt;br /&gt;    return 1&lt;br /&gt;  else:&lt;br /&gt;    return -1&lt;br /&gt;&lt;br /&gt;input=file("data.txt","r")    #open data file&lt;br /&gt;plot=file("pie.gnuplot","w")    #open plot script file&lt;br /&gt;&lt;br /&gt;#Some plot commands&lt;br /&gt;plotcommand='''&lt;br /&gt;reset&lt;br /&gt;set term png    #terminal and output file&lt;br /&gt;set output "pie.png"&lt;br /&gt;set size square    #square size&lt;br /&gt;set isosample 50,50    #samples&lt;br /&gt;set parametric    #parametric mode on&lt;br /&gt;set xrange [-1:1]    #x,y,v range&lt;br /&gt;set yrange [-1:1]&lt;br /&gt;set vrange [0:1]&lt;br /&gt;unset border    #no border, tics and colorbox&lt;br /&gt;unset xtics&lt;br /&gt;unset ytics&lt;br /&gt;unset colorbox&lt;br /&gt;set view map    #the view point&lt;br /&gt;set palette defined(0 "red",1 "green",2 "blue",\\&lt;br /&gt;    3 "yellow",4 "cyan",5 "brown",6 "greenyellow",\\&lt;br /&gt;    7 "gray",8"bisque",9"violet",10"black")&lt;br /&gt;#The color palette&lt;br /&gt;set cbrange [0:10]&lt;br /&gt;set multiplot    #multiplot mode&lt;br /&gt;'''&lt;br /&gt;plot.write(plotcommand)&lt;br /&gt;#output the commands to plot script file&lt;br /&gt;u_begin=0.&lt;br /&gt;#The begin value of u(dummy variable in parametric plot)&lt;br /&gt;i=0.	#The item indicate&lt;br /&gt;while True:&lt;br /&gt;  ##Read data&lt;br /&gt;  data=input.readline()&lt;br /&gt;  if len(data)==0:    #if end of data file, break&lt;br /&gt;    break&lt;br /&gt;  data=data.split()&lt;br /&gt;&lt;br /&gt;  ##Caculate some parameters&lt;br /&gt;  u_end=u_begin+float(data[1])    #end value of u&lt;br /&gt;  ang=(u_begin+u_end)*math.pi    #the angle lables will be rotated&lt;br /&gt;  x=math.cos(ang)&lt;br /&gt;  x=x+sign(x)*0.2    #x value of label position&lt;br /&gt;  y=math.sin(ang)&lt;br /&gt;  y=y+sign(y)*0.2    #y value of label position&lt;br /&gt;&lt;br /&gt;  ##Output some plot commands&lt;br /&gt;  plot.write("set urange [%f*2*pi:%f*2*pi]\n" \&lt;br /&gt;  %(u_begin,u_end))    #command set the range of variable u&lt;br /&gt;  plot.write('set label %d center "%s" at %f,%f rotate \&lt;br /&gt;  by %f*180/pi\n' %(int(i+1),data[0],x,y,ang))&lt;br /&gt;  #command set the labels&lt;br /&gt;  plot.write("splot cos(u)*v,sin(u)*v,%f w pm3d \&lt;br /&gt;  notitle\n" %i)&lt;br /&gt;  #command plot a sector&lt;br /&gt;&lt;br /&gt;  u_begin=u_end    #the next begin value of u&lt;br /&gt;  i=i+1&lt;br /&gt;&lt;br /&gt;plot.write("unset multiplot")	#plot command&lt;br /&gt;&lt;br /&gt;input.close()    #close files&lt;br /&gt;plot.close()&lt;br /&gt;&lt;br /&gt;os.system("gnuplot plot.gplt")    #execute the plot script&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Note that although we use a python script, the plot is done by gnuplot. Python is used only to create the gnuplot plot script, i.e., to do some text work.&lt;br /&gt;&lt;br /&gt;Run this python script we get a gnuplot script named pie.gnuplot and the following pie chart.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Zm-2IU0nh-s/TohhwrlIoFI/AAAAAAAAAKg/DaQEvmxUjak/s1600/pie.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-Zm-2IU0nh-s/TohhwrlIoFI/AAAAAAAAAKg/DaQEvmxUjak/s320/pie.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Pie chart created by gnuplot with assistance of python&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-2332954042321374975?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/2332954042321374975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/pie-chart-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2332954042321374975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2332954042321374975'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/pie-chart-in-gnuplot.html' title='Pie chart in gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-cpTH0oydK-g/Tohfjz79pWI/AAAAAAAAAKc/N1Wkckoanh4/s72-c/sector.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-5007869453940776948</id><published>2011-10-01T06:13:00.000-07:00</published><updated>2012-02-17T22:57:09.968-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='script'/><category scheme='http://www.blogger.com/atom/ns#' term='Rectangle'/><title type='text'>Round corner rectangle in gnuplot</title><content type='html'>A simple rectangle always looks too hard while a round corner rectangle looks more comfortable. In this article I will talk about how to create an round corner rectangle in gnuplot.&lt;br /&gt;&lt;br /&gt;There is rectangle object in gnuplot, but unfortunately there seems no option to set it a round corner one. So an absolutely new method will be used. I will use plot style "filledcurve" to create an round corner rectangle. Now come to the script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;###############################################&lt;br /&gt;#Variables:&lt;br /&gt;##(a,b) is the low left vertex of the rectangle&lt;br /&gt;##(c,d) is the up right vertex of the rectangle&lt;br /&gt;##rx is the radius along x-axis&lt;br /&gt;##ry is the radius along y-axis&lt;br /&gt;##x is the independent variable of the curve&lt;br /&gt;f_low(a,b,c,d,rx,ry,x)=a&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;a+rx ? \&lt;br /&gt;     -ry*sqrt(1-((x-a-rx)/rx)**2)+b+ry : \&lt;br /&gt;     a+rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c-rx ? b :c-rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c ?\&lt;br /&gt;     -ry*sqrt(1-((x-c+rx)/rx)**2)+b+ry : 1/0&lt;br /&gt;#The low curve of a round corner rectangle&lt;br /&gt;f_up(a,b,c,d,rx,ry,x)=a&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;a+rx ?\&lt;br /&gt;     ry*sqrt(1-((x-a-rx)/rx)**2)+d-ry : \&lt;br /&gt;     a+rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c-rx ? d :c-rx&amp;lt;x &amp;amp;&amp;amp; x&amp;lt;c ?\&lt;br /&gt;     ry*sqrt(1-((x-c+rx)/rx)**2)+d-ry : 1/0&lt;br /&gt;#The up curve of a round corner rectangle&lt;br /&gt;###############################################&lt;br /&gt;unset border    #no border&lt;br /&gt;unset tics    #no tics&lt;br /&gt;set sample 1000&lt;br /&gt;set xrange [-10:10]&lt;br /&gt;set yrange [-10:10]&lt;br /&gt;set term png&lt;br /&gt;set output "round_corner_rectangle.png"&lt;br /&gt;plot '+' u 1:(f_low(-10,-10,10,10,1,2,$1)):\&lt;br /&gt;     (f_up(-10,-10,10,10,1,2,$1)) w filledcurve\&lt;br /&gt;     lc rgb"pink" notitle&lt;br /&gt;#plot a round corner rectangle &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Load the plotting script, and we get picture file found_corner_rectangle.png like this.&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-9B4u8hRnRso/TocRkEOGllI/AAAAAAAAAKY/qxJnsG2rftY/s1600/round_corner_rectangle.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-9B4u8hRnRso/TocRkEOGllI/AAAAAAAAAKY/qxJnsG2rftY/s320/round_corner_rectangle.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Round corner rectangle created using filledcurve plot style in gunplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-5007869453940776948?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/5007869453940776948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/round-corner-rectangle-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5007869453940776948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5007869453940776948'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/10/round-corner-rectangle-in-gnuplot.html' title='Round corner rectangle in gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-9B4u8hRnRso/TocRkEOGllI/AAAAAAAAAKY/qxJnsG2rftY/s72-c/round_corner_rectangle.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-7467623358284275895</id><published>2011-09-30T07:58:00.000-07:00</published><updated>2012-02-17T22:57:26.832-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='script'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot binary'/><title type='text'>Rotate a picture using gnuplot</title><content type='html'>Last time I promised rotating a picture using gnuplot will be talked. Today I come to realize my promise.Let us look at the script at first.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#Utility:Convert a rgb colorized image to a gray one&lt;br /&gt;#Author:数声风笛离亭晚，我想潇湘君想秦！&lt;br /&gt;#Email：qinjieli@gmail.com&lt;br /&gt;#Usage:&lt;br /&gt;##call "rotate.gnuplot" angle inputfile outputfile&lt;br /&gt;#parameters:&lt;br /&gt;##angle: the angle to be rotated&lt;br /&gt;##inputfile: input filename (without ".png")&lt;br /&gt;##outputfile: outputfilename (without ".png")&lt;br /&gt;reset&lt;br /&gt;angle=$0    #angle to be rotated&lt;br /&gt;angle=angle*pi/180    #change degrees to radians&lt;br /&gt;inputfile="$1.png"    #input file&lt;br /&gt;outputfile="$2.png"    #ouput file&lt;br /&gt;set size ratio -1&lt;br /&gt;# Set the scales so that the unit has the same length&lt;br /&gt;#on both the x and y axes&lt;br /&gt;set lmargin 0    #nO margin&lt;br /&gt;set rmargin 0&lt;br /&gt;set tmargin 0&lt;br /&gt;set bmargin 0&lt;br /&gt;unset tics    #no tics and border line&lt;br /&gt;unset border&lt;br /&gt;#plot and get the size of the rotated picture&lt;br /&gt;plot inputfile binary filetype=png rotate=angle w rgbima notitle&lt;br /&gt;xmax=GPVAL_DATA_X_MAX&lt;br /&gt;xmin=GPVAL_DATA_X_MIN&lt;br /&gt;ymin=GPVAL_DATA_Y_MIN&lt;br /&gt;ymax=GPVAL_DATA_Y_MAX&lt;br /&gt;set xrange [xmin:xmax]    #set x and y range&lt;br /&gt;set yrange [ymin:ymax]&lt;br /&gt;set term png truecolor size (xmax-xmin),(ymax-ymin)    #set the terminal&lt;br /&gt;set output outputfile&lt;br /&gt;plot inputfile binary filetype=png rotate=angle w rgbima notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The script first plot the plot the rotated picture on screen. This plot has two functions, determining the size of the output picture and letting the user have view at the rotated picture. Save the script as "rotate.gnuplot", and then it can be called like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;gnuplot&amp;gt; call "rotate.gnuplot" 30 input output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;At last is one of our finished work.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s1600/input1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s320/input1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Input picture file (initial file download from &lt;a href="http://www.flickr.com/photos/2493/1078598654/sizes/z/in/photostream/"&gt;here&lt;/a&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-fOsG2cN2_Ro/ToXYGvSwO_I/AAAAAAAAAKA/mW4e71kIPzg/s1600/output.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="287" src="http://4.bp.blogspot.com/-fOsG2cN2_Ro/ToXYGvSwO_I/AAAAAAAAAKA/mW4e71kIPzg/s320/output.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Picture rotated by 30 degree using our script&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-7467623358284275895?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/7467623358284275895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/rotate-picture-using-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7467623358284275895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7467623358284275895'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/rotate-picture-using-gnuplot.html' title='Rotate a picture using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s72-c/input1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6615916114045542732</id><published>2011-09-29T06:23:00.000-07:00</published><updated>2011-09-30T07:58:13.998-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot binary'/><title type='text'>Crop picture using gnuplot</title><content type='html'>We talked about converting a rgb image to a gray one using gnuplot last time. Except this, Gnuplot also can do some other manipulations such as cropping, rotating and so on. In this article and next few ones I will talk about them respectively. This time we deal with cropping.&lt;br /&gt;&lt;br /&gt;Cropping is selecting specific area from the picture, then drawing it to an output file. In gnuplot this can be done by setting the xrange and yrnage to a proper value and then plot. The script is shown below.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#Utility: crop png pictures using gnuplot.&lt;br /&gt;#Author:数声风笛离亭晚，我想潇湘君想秦！&lt;br /&gt;#Email：qinjieli@gmail.com&lt;br /&gt;#Usage:&lt;br /&gt;##call "crop.gnuplot" x1 y1 x2 y2 inputfile outputfile&lt;br /&gt;#parameters:&lt;br /&gt;##x1: x-value of left-bottom point&lt;br /&gt;##y1: y-value of left-bottom point&lt;br /&gt;##x2: x-value of right-top point&lt;br /&gt;##y2: y-value of right-top point&lt;br /&gt;##inputfile: input filename (without ".png")&lt;br /&gt;##outputfile: output filename (without ".png")&lt;br /&gt;reset&lt;br /&gt;x1="$0"   #The left bottom point&lt;br /&gt;y1="$1"&lt;br /&gt;x2="$2"   #The right top point&lt;br /&gt;y2="$3"&lt;br /&gt;inputfile="$4.png"    #inputfile name&lt;br /&gt;outputfile="$5.png"   #outputfile name&lt;br /&gt;set xrange [x1:x2]&lt;br /&gt;set yrange [y1:y2]&lt;br /&gt;set size ratio -1&lt;br /&gt;# Set the scales so that the unit has the same length&lt;br /&gt;#on both the x and y axes&lt;br /&gt;#There shold be no margin&lt;br /&gt;set lmargin 0&lt;br /&gt;set rmargin 0&lt;br /&gt;set tmargin 0&lt;br /&gt;set bmargin 0&lt;br /&gt;#There shold be no key tics and border&lt;br /&gt;unset key&lt;br /&gt;unset tics&lt;br /&gt;unset border&lt;br /&gt;set term png truecolor size (x2-x1),(y2-y1)&lt;br /&gt;set output outputfile&lt;br /&gt;plot inputfile binary filetype=png w rgbimage&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Save this script as "crop.gnuplot". Then it can be called from gnuplot like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;gnuplot&amp;gt; call "crop.gnuplot" x1 y1 x2 y2 inputfile outputfile&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In the end as usual let me show a finished work.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s1600/input1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s320/input1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Input picture file (initial file download from &lt;a href="http://www.flickr.com/photos/2493/1078598654/sizes/z/in/photostream/"&gt;here&lt;/a&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-LId6U9gi3O8/ToRv4rOY-vI/AAAAAAAAAJ4/JU4O2QMLKbY/s1600/output.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-LId6U9gi3O8/ToRv4rOY-vI/AAAAAAAAAJ4/JU4O2QMLKbY/s1600/output.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Picture cropped using command "call "plot.gplt" 250 150 500 400 input output"&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6615916114045542732?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6615916114045542732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/crop-picture-using-gnuplot.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6615916114045542732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6615916114045542732'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/crop-picture-using-gnuplot.html' title='Crop picture using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s72-c/input1.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-8172521675686736979</id><published>2011-09-27T03:49:00.000-07:00</published><updated>2012-02-17T22:57:39.725-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gray color'/><category scheme='http://www.blogger.com/atom/ns#' term='rgb color'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot binary'/><title type='text'>Convert a rgb colorized png picture to a gray one using gnuplot</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-jwRSCLzyUKM/ToGl7B4719I/AAAAAAAAAGo/QMtBnIv7jCU/s1600/output2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;I will talk about convert a colorized rgb image to a gray one using gnuplot in this article.&lt;br /&gt;Amazing it is to edit pictures with gnuplot. Yes, it is a little amazing, this kind of works should left to picture editors in fact. But I will show you gnuplot can also do it well.&lt;br /&gt;In a rgb image, the color of a point is marked with (r,g,b) where r,g and b can be and always are diffrent values. While for a gray one r,g and b must be the same. So to convert a rgb image to a gray one, we should convert (r,g,b) to (gray,gray,gray). Once we known how to do it, the problem becomes easy. Now we come to write our gnuplot script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#Utility:Convert a rgb colorized image to a gray one&lt;br /&gt;#Author:数声风笛离亭晚，我想潇湘君想秦！&lt;br /&gt;#Email：qinjieli@gmail.com&lt;br /&gt;#Usage:&lt;br /&gt;##call "rgbtogray.gnuplot" inputfile outputfile&lt;br /&gt;#parameters:&lt;br /&gt;##inputfile: input filename (without ".png")&lt;br /&gt;##outputfile: outputfilename (without ".png")&lt;br /&gt;reset&lt;br /&gt;inputfile="$0.png"&lt;br /&gt;outputfile="$1.png"&lt;br /&gt;plot inputfile binary filetype=png w rgbimage&lt;br /&gt;xmax=GPVAL_DATA_X_MAX&lt;br /&gt;xmin=GPVAL_DATA_X_MIN&lt;br /&gt;ymin=GPVAL_DATA_Y_MIN&lt;br /&gt;ymax=GPVAL_DATA_Y_MAX&lt;br /&gt;set xrange [xmin:xmax]&lt;br /&gt;set yrange [ymin:ymax]&lt;br /&gt;#get the size of the picture&lt;br /&gt;gray(r,g,b)=0.299*r + 0.587*g + 0.114*b&lt;br /&gt;#The function which convert rgb color to gray.&lt;br /&gt;#At first I choose the three weighting all to be 0.333,&lt;br /&gt;#but a firend told me it will be better to use these values&lt;br /&gt;set size ratio -1&lt;br /&gt;# Set the scales so that the unit has the same length&lt;br /&gt;#on both the x and y axes&lt;br /&gt;#########################&lt;br /&gt;#There should not be any margin in the output picture&lt;br /&gt;set lmargin 0&lt;br /&gt;set rmargin 0&lt;br /&gt;set tmargin 0&lt;br /&gt;set bmargin 0&lt;br /&gt;unset key   #The key, border and tics are all do not need&lt;br /&gt;unset border&lt;br /&gt;unset tics&lt;br /&gt;#set terminal and output file name&lt;br /&gt;set term png size (xmax-xmin),(ymax-ymin)&lt;br /&gt;set output outputfile&lt;br /&gt;#Plot with gray color&lt;br /&gt;plot inputfile\&lt;br /&gt;     u (gray(column(1),column(2),column(3))):\&lt;br /&gt;       (gray(column(1),column(2),column(3))):\&lt;br /&gt;       (gray(column(1),column(2),column(3)))\&lt;br /&gt;     binary filetype=png w rgbimage&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Save the script as "rgbtogray.gnuplot", then it can be called like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;gnuplot&amp;gt; call "rgbtogray.gnuplot" inputfile outputfile&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The following is two groups of our input and ouput files. The initial input files are copied from &lt;a href="http://www.flickr.com/photos/2493/1078599494/sizes/z/in/photostream/"&gt;here&lt;/a&gt; and &lt;a href="http://www.flickr.com/photos/2493/1078598654/sizes/z/in/photostream/"&gt;here&lt;/a&gt; (Thanks the original picture author!).&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-je6SANcf3Mw/ToGl7cEatdI/AAAAAAAAAGs/4gNefPD-HE8/s1600/input2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-je6SANcf3Mw/ToGl7cEatdI/AAAAAAAAAGs/4gNefPD-HE8/s320/input2.png" width="240" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Input file-1&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-jwRSCLzyUKM/ToGl7B4719I/AAAAAAAAAGo/QMtBnIv7jCU/s1600/output2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/-jwRSCLzyUKM/ToGl7B4719I/AAAAAAAAAGo/QMtBnIv7jCU/s320/output2.png" width="240" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Output file-1&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s1600/input1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://4.bp.blogspot.com/-g4J1zGtrT34/ToGl7FZa0nI/AAAAAAAAAGk/gKzx12b-g5s/s320/input1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Input file-2&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Cwqt1AXqsbI/ToGl6RQnSfI/AAAAAAAAAGg/-9vKUttPuaU/s1600/output1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://3.bp.blogspot.com/-Cwqt1AXqsbI/ToGl6RQnSfI/AAAAAAAAAGg/-9vKUttPuaU/s320/output1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Output file-2&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-8172521675686736979?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/8172521675686736979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/convert-colorized-png-picture-to-gray.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8172521675686736979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8172521675686736979'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/convert-colorized-png-picture-to-gray.html' title='Convert a rgb colorized png picture to a gray one using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-je6SANcf3Mw/ToGl7cEatdI/AAAAAAAAAGs/4gNefPD-HE8/s72-c/input2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-3679241397522461746</id><published>2011-09-24T05:13:00.002-07:00</published><updated>2011-09-24T05:15:44.565-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='contour plot'/><category scheme='http://www.blogger.com/atom/ns#' term='implicit plot'/><title type='text'>Implicit function plotting using gnuplot</title><content type='html'>Assume three is an equation f(x,y)=g(x,y), and we want to plot the roots which obey this equation. This is a typical implicit function plotting problem. How do we handle this problem using gnuplot?&lt;br /&gt;&lt;br /&gt;The most simple idea is solving the equation analytically (or numerically), and get the the root y=h(x) (or a data file containing the roots). Then plot h(x) (or the data file) with gnuplot. Of course, it is OK. But here we provide a more simpler method. &lt;br /&gt;&lt;br /&gt;Note that the contour line at level 0 for function z=f(x,y)-g(x,y) is just the lines made up by the points which obey equation f(x,y)=g(x,y). So we can convert implicit function plotting problem to a contour plotting problem. Now come to a example.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png enhanced lw 2 font "Times,18"&lt;br /&gt;set output "implicit.png"&lt;br /&gt;set contour&lt;br /&gt;set cntrparam levels discrete 0&lt;br /&gt;set view map&lt;br /&gt;unset surface&lt;br /&gt;set nokey&lt;br /&gt;set isosamples 1000,1000&lt;br /&gt;set xrange [-2:2]&lt;br /&gt;set yrange [-2:2]&lt;br /&gt;set xlabel "x"&lt;br /&gt;set ylabel "y"&lt;br /&gt;set title "Implicit plot of sin(x^2+y^2)=exp(-xy)"&lt;br /&gt;splot sin(x**2+y**2)-exp(-x*y)&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Picture implicit.png is as follows.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-JjXOrbnSt0I/Tn3I4JKHY6I/AAAAAAAAAGY/1w8m1lFqun4/s1600/implicit.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-JjXOrbnSt0I/Tn3I4JKHY6I/AAAAAAAAAGY/1w8m1lFqun4/s320/implicit.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Implicit Plot Using Gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-3679241397522461746?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/3679241397522461746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/assume-three-is-equation-fxygxy-and-we.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3679241397522461746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/3679241397522461746'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/assume-three-is-equation-fxygxy-and-we.html' title='Implicit function plotting using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-JjXOrbnSt0I/Tn3I4JKHY6I/AAAAAAAAAGY/1w8m1lFqun4/s72-c/implicit.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-1102997291790703059</id><published>2011-09-22T04:01:00.000-07:00</published><updated>2011-12-23T03:46:38.586-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='animation'/><title type='text'>Creating gif animation using gnuplot</title><content type='html'>Some times an animation makes thing much easier to be understood. When I was in middle school, I can not understand the propagation of wave well although the teacher took great effort to explain it to me. At last he show me an animation of propagating wave, at the instance i understand it. So can gnuplot create such a powerful thing? The answer is yes. Under gif terminal, if the animate option is selected, Gnuplot will thought each plot as a frame of an animation. Next is an example.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#We will plot sin(x+t) in this gif animation&lt;br /&gt;reset&lt;br /&gt;set term gif animate&lt;br /&gt;n=24    #n frame&lt;br /&gt;dt=2*pi/24&lt;br /&gt;set xrange [0:4*pi]&lt;br /&gt;i=0&lt;br /&gt;load "animate.gnuplot"&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;where file animate.gnuplot contain the following gnuplot commands:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;plot sin(x+i*dt) w l lt 1 lw 1.5 notitle&lt;br /&gt;i=i+1&lt;br /&gt;if (i &amp;lt; n) reread&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Note you can not use "plot for ..." to create an animation, because gnuplot will look it as a single plot and will only create a single frame. Run the script we get an animation as &lt;a href="https://picasaweb.google.com/lh/photo/rmnCdQ0F7pwH-QFsvVvIhA?feat=directlink"&gt;this&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh4.googleusercontent.com/-DLBaCAwd_dI/TnsVLjUGs2I/AAAAAAAAAGQ/ILITkTuB9fg/s640/animate.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="https://lh4.googleusercontent.com/-DLBaCAwd_dI/TnsVLjUGs2I/AAAAAAAAAGQ/ILITkTuB9fg/s640/animate.gif" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-1102997291790703059?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/1102997291790703059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/creating-gif-animation-using-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1102997291790703059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/1102997291790703059'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/creating-gif-animation-using-gnuplot.html' title='Creating gif animation using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh4.googleusercontent.com/-DLBaCAwd_dI/TnsVLjUGs2I/AAAAAAAAAGQ/ILITkTuB9fg/s72-c/animate.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-4641772217981325944</id><published>2011-09-20T04:58:00.000-07:00</published><updated>2011-09-20T05:00:00.513-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='I/O'/><title type='text'>Gnuplot I/O: Use fit command to scanf data from files</title><content type='html'>We usually record our data as follows:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;x0         y0&lt;br /&gt;x0+dx      y1&lt;br /&gt;x0+2*dx    y2&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In fact there is so much redundancy. For the first column we only need to record two numbers x0 and dx. So in a compact format the data can be stored as:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;x0&lt;br /&gt;dx&lt;br /&gt;y0&lt;br /&gt;y1&lt;br /&gt;y2&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Some one may say "these days the memory is so cheap, I do not care the bytes". But have you consider the speed? When you come to process the data, the larger the data file is, the longer time will your program takes. So this new format is worthy.&lt;br /&gt;&lt;br /&gt;But problems raised when you want to plot the data file using gnuplot. The software do not recognize this new format. So the task of this article is making gnuplot understand this format.&lt;br /&gt;&lt;br /&gt;Firstly we need to read x0 and dx out form the file. As for gnupot there is no functions like scanf in c programming language, we need to play a trick here. We use command fit to read the data out. We known that if there is only two point, the fitting result using function f(x)=a*x+b will be exact. So we use command&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;fit f(x) "my_format.dat" u 0:1 every ::0::1 via a,b&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;to fit the first two points. Then we get x0=f(0), dx=f(1). Now the xvalue can be generated by x0+$0*dx. As the xvalue has been prepared, we can come to plot the data file. Now Let me show an example. The plotting script reads:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png font "Times,18"&lt;br /&gt;set output "my_format.png"&lt;br /&gt;f(x)=a*x+b&lt;br /&gt;fit f(x) "my_format.dat" u 0:1 every ::0::1 via a,b&lt;br /&gt;x0=f(0)&lt;br /&gt;dx=f(1)&lt;br /&gt;set xlabel "Time(ms)"&lt;br /&gt;set ylabel "Light Intensity(Arbitary Unit)"&lt;br /&gt;set mxtics 5&lt;br /&gt;set mytics 2&lt;br /&gt;set grid xtics mxtics ytics mytics&lt;br /&gt;set offset 0,0,0.05,0&lt;br /&gt;plot "my_format.dat" u (x0+$0*dx):1 every ::2 with lines linewidth 2 notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Data file my_format.dat can be downloaded &lt;a href="https://docs.google.com/leaf?id=0B5wSAiwiTq4gZGZiNzljMWQtMDViNC00YWQxLTk4ZDMtNzE4MWZjYWM1NmU4&amp;amp;hl=zh_CN"&gt;here&lt;/a&gt;. And the graph is shown below.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-G8AJtHoRAhU/Tnh_Zxyw6TI/AAAAAAAAAFY/5VtjbEfxvQQ/s1600/my_format.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-G8AJtHoRAhU/Tnh_Zxyw6TI/AAAAAAAAAFY/5VtjbEfxvQQ/s320/my_format.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-4641772217981325944?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/4641772217981325944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gnuplot-io-use-fit-command-to-scanf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/4641772217981325944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/4641772217981325944'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gnuplot-io-use-fit-command-to-scanf.html' title='Gnuplot I/O: Use fit command to scanf data from files'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-G8AJtHoRAhU/Tnh_Zxyw6TI/AAAAAAAAAFY/5VtjbEfxvQQ/s72-c/my_format.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-9117358116924669173</id><published>2011-09-18T05:56:00.000-07:00</published><updated>2011-09-18T06:19:27.748-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='transparency'/><title type='text'>transparency in gnuplot</title><content type='html'>There is options to set the fill color in gnuplot to be transparent. But some friends of mine ofen complained that it never works. This is because to let the transparency really work, you also need to choose a transparency supported terminal type. For raster graphics "png" may be a choice, and for vector graphics it may be "pdf". You can use command "help transparent" to see the details.&lt;br /&gt;There is an example.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;f(v,T)=4/sqrt(pi*T**3)*exp(-v**2/T)*v**2&lt;br /&gt;set sample 500&lt;br /&gt;set title "Maxwell speed distribution"&lt;br /&gt;set xlabel "Speed [(2kT_c/m)^{1/2}]"&lt;br /&gt;set ylabel "Probability Intensity f(v)"&lt;br /&gt;set style fill transparent solid 0.5&lt;br /&gt;set key Left&lt;br /&gt;set term png truecolor enhanced font "Times,15"&lt;br /&gt;set output "maxwell_speed_distribution.png"&lt;br /&gt;plot [0:5] f(x,0.1) w filledcurves x1 title "T=0.1T_c",\&lt;br /&gt;           f(x,1)   w filledcurves x1 title "T=T_c",\&lt;br /&gt;           f(x,5)   w filledcurves x1 title "T=5T_c"&lt;br /&gt;set term pdf enhanced&lt;br /&gt;set output "maxwell_speed_distribution.pdf"&lt;br /&gt;replot&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Note that when transparency is used in png terminal, the "truecolor" option must be selected.&lt;br /&gt;&lt;br /&gt;The png file is shown below and the pdf file can be downloaded &lt;a href="https://docs.google.com/viewer?a=v&amp;amp;pid=explorer&amp;amp;chrome=true&amp;amp;srcid=0B5wSAiwiTq4gMDk3N2M0MDYtYjU2Mi00ZmE1LTgyMGQtNmU4MDU1MmQ1NWQ5&amp;amp;hl=zh_CN"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-SF3mN0cKS_4/TnXqBDZ8x1I/AAAAAAAAAFQ/mLxcfJM87Xg/s1600/maxwell_speed_distribution.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-SF3mN0cKS_4/TnXqBDZ8x1I/AAAAAAAAAFQ/mLxcfJM87Xg/s320/maxwell_speed_distribution.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-9117358116924669173?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/9117358116924669173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/transparency-in-gnuplot.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/9117358116924669173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/9117358116924669173'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/transparency-in-gnuplot.html' title='transparency in gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-SF3mN0cKS_4/TnXqBDZ8x1I/AAAAAAAAAFQ/mLxcfJM87Xg/s72-c/maxwell_speed_distribution.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-9082041601722073528</id><published>2011-09-17T03:28:00.000-07:00</published><updated>2011-09-17T03:29:51.561-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='histogram'/><category scheme='http://www.blogger.com/atom/ns#' term='transparency'/><title type='text'>Plot histograms using boxes</title><content type='html'>Some one may ask:"There is histogram plot style in gnuplot, why plot it with boxes?" I would like to say there is some restriction on the built in histogram plot style, for example the x-axis is always using the row number, you can not make it using the coloumns in the data file.&lt;br /&gt;&lt;br /&gt;The simplest case is that there is only one group of data to be plotted. In this case you just set the boxwidth to a proper value, for example 0.95, and plot it with boxes. Here is an example.&lt;br /&gt;The data file is like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;1975    0.5     9.0&lt;br /&gt;1980    2.0     12.0&lt;br /&gt;1985    2.5     10.1&lt;br /&gt;1990    2.6     9.1&lt;br /&gt;1995    2.0     7.2&lt;br /&gt;2000    5.0     8.0&lt;br /&gt;2005    10.2    6.0&lt;br /&gt;2010    15.1    6.2&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The plotting script is like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png truecolor&lt;br /&gt;set output "profit.png"&lt;br /&gt;set xlabel "Year"&lt;br /&gt;set ylabel "Profit(Million Dollars)"&lt;br /&gt;set grid&lt;br /&gt;set boxwidth 0.95 relative&lt;br /&gt;set style fill transparent solid 0.5 noborder&lt;br /&gt;plot "profit.dat" u 1:2 w boxes lc rgb"green" notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;This example plot a graph like this one:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-Qvbmhl8OfMo/TnR0FmR1N3I/AAAAAAAAAFI/lhGNjJdHN0U/s1600/profit.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-Qvbmhl8OfMo/TnR0FmR1N3I/AAAAAAAAAFI/lhGNjJdHN0U/s320/profit.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Plot histogram using boxes with one group of data&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;When there is more than one group of data to plot, the boxwidth and gap between the boxes should be calculated carefully. We do it like this:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;dx=5.&lt;br /&gt;n=2&lt;br /&gt;total_box_width_relative=0.75&lt;br /&gt;gap_width_relative=0.1&lt;br /&gt;d_width=(gap_width_relative+total_box_width_relative)*dx/2.&lt;br /&gt;reset&lt;br /&gt;set term png truecolor&lt;br /&gt;set output "profit.png"&lt;br /&gt;set xlabel "Year"&lt;br /&gt;set ylabel "Profit(Million Dollars)"&lt;br /&gt;set grid&lt;br /&gt;set boxwidth total_box_width_relative/n relative&lt;br /&gt;set style fill transparent solid 0.5 noborder&lt;br /&gt;plot "profit.dat" u 1:2 w boxes lc rgb"green" notitle,\&lt;br /&gt;     "profit.dat" u ($1+d_width):3 w boxes lc rgb"red" notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;This time we get a histogram with two group of data like this:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-I8cJds_rSbo/TnR1xYIcKpI/AAAAAAAAAFM/j0Scm8FflX8/s1600/profit.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-I8cJds_rSbo/TnR1xYIcKpI/AAAAAAAAAFM/j0Scm8FflX8/s320/profit.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Plot histogram using boxes with more than one group of data&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-9082041601722073528?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/9082041601722073528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/plot-histograms-using-boxes.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/9082041601722073528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/9082041601722073528'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/plot-histograms-using-boxes.html' title='Plot histograms using boxes'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-Qvbmhl8OfMo/TnR0FmR1N3I/AAAAAAAAAFI/lhGNjJdHN0U/s72-c/profit.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-5046213594440809450</id><published>2011-09-16T04:34:00.000-07:00</published><updated>2011-09-16T04:37:31.745-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistic'/><category scheme='http://www.blogger.com/atom/ns#' term='data manipulation'/><title type='text'>Statistic analysis using gnuplot (1)</title><content type='html'>Last time we dealt with the maximum, minimum and mean value of a statistic analysis problem. Today the standard deviation will be added.&lt;br /&gt;The standard deviation is defined as the square root of the variance. With variance stand for the mean squared value minus the squared mean value. The mean value have been dealt last time. We just need to store it. Strange it is, although there is only one data point after the smooth, when I plot it to a data file using the table mode, I get two output points with the second one marked with "u" which means undefined value.(who can tell me why?) In a similar way we plot the mean of squared value to another data file. Next we read this two value out from the data file. And use them to calculate the standard deviation. Since there is only two data points in the file, we use f(x)=ax+b to fit the data, and the fitted result will be exact, then we can use f(x) to get these exact values. At last we plot the standard deviation on the graph. The following is our final plotting script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;plot "rand_t.dat" u 1:2	#To get the max and min value&lt;br /&gt;ymax=GPVAL_DATA_Y_MAX&lt;br /&gt;ymin=GPVAL_DATA_Y_MIN&lt;br /&gt;ylen=ymax-ymin&lt;br /&gt;xmax=GPVAL_DATA_X_MAX&lt;br /&gt;xmin=GPVAL_DATA_X_MIN&lt;br /&gt;xlen=xmax-xmin&lt;br /&gt;set table "mean.txt"	#put the mean value out&lt;br /&gt;plot "rand_t.dat" u ((xmax+xmin)/2.0):($2) smooth unique w p&lt;br /&gt;unset table&lt;br /&gt;set table "mean_squared.txt"	#put the mean of squared value out&lt;br /&gt;plot "rand_t.dat" u ((xmax+xmin)/2.0):($2**2) smooth unique w p&lt;br /&gt;unset table&lt;br /&gt;f(x)=a*x+b	#The fit functions&lt;br /&gt;g(x)=c*x+d&lt;br /&gt;fit f(x) "mean.txt" u 0:2 via a,b	#Read the mean and mean of squared value&lt;br /&gt;fit g(x) "mean_squared.txt" u 0:2 via c,d&lt;br /&gt;mean=f(0)	#mean value&lt;br /&gt;mean_squared=g(0)	#mean of the squared value&lt;br /&gt;standard_deviation=sqrt(mean_squared-mean**2)	#standard deviation&lt;br /&gt;print "The mean value is ",mean		#print the mean and standard deviation&lt;br /&gt;print "The standard deviation is ",standard_deviation&lt;br /&gt;#plot&lt;br /&gt;set term post eps enhanced color lw 1.5 font ",20"&lt;br /&gt;set output "statistic.eps"&lt;br /&gt;set xrange [xmin:xmax]&lt;br /&gt;set yrange [ymin-0.5*ylen:ymax+0.5*ylen]&lt;br /&gt;set xlabel "time"&lt;br /&gt;set ylabel "Random Signal"&lt;br /&gt;#The labels&lt;br /&gt;set label 1 at (xmin+xmax)/2.,ymax "Maximum" offset 0,0.5&lt;br /&gt;set label 2 at (xmin+xmax)/2.,ymin "Minimum" offset 0,-0.5&lt;br /&gt;set label 3 at (xmin+xmax)/2.,mean "Mean" offset 0,0.5&lt;br /&gt;set label 4 at (xmin+xmax)/2.,mean+3*standard_deviation \&lt;br /&gt;             "Mean+3{/Symbol \163}" offset 0,0.5&lt;br /&gt;set label 5 at (xmin+xmax)/2.,mean-3*standard_deviation \&lt;br /&gt;             "Mean-3{/Symbol \163}" offset 0,-0.5&lt;br /&gt;plot "rand_t.dat" u 1:2 w p pt 7 ps 0.5 notitle,\&lt;br /&gt;     mean w l lt 2 notitle "Mean",\&lt;br /&gt;     ymax w l lt 3 notitle "Maximum",\&lt;br /&gt;     ymin w l lt 3 notitle,\&lt;br /&gt;     mean+3*standard_deviation w l lt 4 notitle,\&lt;br /&gt;     mean-3*standard_deviation w l lt 4 notitle&lt;br /&gt;#the six plot stand for raw data, mean, maximum, minimum,&lt;br /&gt;#3-sigma upper line and 3-sigma lower line&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;At last we get figure like follows.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-Km-Sjo2YASo/TnMzgCuQThI/AAAAAAAAAFE/HxvvL6EGQIc/s1600/statistic.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="223" src="http://2.bp.blogspot.com/-Km-Sjo2YASo/TnMzgCuQThI/AAAAAAAAAFE/HxvvL6EGQIc/s320/statistic.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Statistic analysis using gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-5046213594440809450?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/5046213594440809450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-1.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5046213594440809450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5046213594440809450'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-1.html' title='Statistic analysis using gnuplot (1)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-Km-Sjo2YASo/TnMzgCuQThI/AAAAAAAAAFE/HxvvL6EGQIc/s72-c/statistic.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-2159837544359052644</id><published>2011-09-14T04:28:00.000-07:00</published><updated>2011-09-16T04:37:17.965-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistic'/><category scheme='http://www.blogger.com/atom/ns#' term='data manipulation'/><title type='text'>Statistic analysis using gnuplot (0)</title><content type='html'>I will talk about statistic analysis using gnuplot in this article. The following contents are covered---maximum, minimum, mean value, standard deviation.&lt;br /&gt;&lt;br /&gt;We begin with the maximum and minimum as they are the simplest. There are two gnuplot defined variables (to see all the gnuplot variables use command "show variable all"), GPVAL_DATA_Y_MAX and GPVAL_DATA_Y_MIN. They are the maximum and minmum y value in the data file which you just used to plot. So after plotting you look over the gnuplot defined variables and you find the maximum and minimum values.&lt;br /&gt;&lt;br /&gt;The mean value is a bit difficult. There is no such a gnuplot defined value. To find it out we will play a trick. There is smooth option called "unique" which makes the data monotonic in x and points with the same x-value are replaced by a single point having the average y-value. So it is appropriate for finding the mean value. We use command&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;plot "data_t.dat" u (constant-value):($n) smooth unique w point&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;to plot the mean value. Here constant-value is an arbitrary constant and $n is the column which contains the random data. Note that there is only one point plotted using the above command, so plot style line can not be used. To plot the the mean value using a line we may need to use xerrobars plot style. (Next time I will give a method to plot it using plot style line.)&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;plot "data_t.dat" u (constant-value):($n):(xerrobar-length) smooth unique w xerrorbars&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Now we come to plot the data points, maximum, minimum and mean value to a picture. And standard deviation is left next time.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;plot "rand_t.dat" u 1:2	#To get the max and min value&lt;br /&gt;ymax=GPVAL_DATA_Y_MAX&lt;br /&gt;ymin=GPVAL_DATA_Y_MIN&lt;br /&gt;ylen=ymax-ymin&lt;br /&gt;xmax=GPVAL_DATA_X_MAX&lt;br /&gt;xmin=GPVAL_DATA_X_MIN&lt;br /&gt;xlen=xmax-xmin&lt;br /&gt;#plot&lt;br /&gt;set term png&lt;br /&gt;set output "statistic.png"&lt;br /&gt;set xrange [xmin:xmax]&lt;br /&gt;set yrange [ymin-0.5*ylen:ymax+0.5*ylen]&lt;br /&gt;set xlabel "time(ms)"&lt;br /&gt;set ylabel "Random Signal(Arbitary Unit)"&lt;br /&gt;plot "rand_t.dat" u 1:2 w p pt 7 ps 0.5 notitle,\&lt;br /&gt;     "rand_t.dat" u (xmax+0.1*xlen):($2):(1.1*xlen)\&lt;br /&gt;     smooth unique w xerrorbars notitle,\&lt;br /&gt;     ymax w l lt 3 notitle,\&lt;br /&gt;     ymin w l lt 3 notitle&lt;br /&gt;#plot raw data, mean value, maximun and minimun respectively&lt;br /&gt;#There is only one data point for the mean value. To make it &lt;br /&gt;#looks like a line, we plot it using a xerrorbars plot style.&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;rand_t.dat can be downloaded &lt;a href="https://docs.google.com/leaf?id=0B5wSAiwiTq4gNDdhNjRlYzctYmJjMi00ZjQ3LWIwZGQtMzVjNTAyMTFmM2Iz&amp;amp;hl=zh_CN"&gt;here&lt;/a&gt;. Picture statistic.png is shown below.&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-4NWN1i8BWq4/TnCOhcz7bdI/AAAAAAAAAFA/Yb3GCYua9zo/s1600/statistic.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-4NWN1i8BWq4/TnCOhcz7bdI/AAAAAAAAAFA/Yb3GCYua9zo/s320/statistic.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Statistic analysis using gnuplot--maximum,minimum and mean value&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-2159837544359052644?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/2159837544359052644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-0.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2159837544359052644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/2159837544359052644'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-using-gnuplot-0.html' title='Statistic analysis using gnuplot (0)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-4NWN1i8BWq4/TnCOhcz7bdI/AAAAAAAAAFA/Yb3GCYua9zo/s72-c/statistic.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-876642733768123608</id><published>2011-09-11T06:30:00.000-07:00</published><updated>2011-09-11T06:39:09.959-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='histogram'/><category scheme='http://www.blogger.com/atom/ns#' term='data manipulation'/><title type='text'>Statistic analysis and histogram plotting using gnuplot</title><content type='html'>Given a data file containing a set of data, count how many datas locate in intervals [a1:a2],[a2:a3]... respectively, then plot the result into a histogram. This a common problem in statistics and exactly what we will do in this article.&lt;br /&gt;&lt;br /&gt;Firstly, let us see how to map the data into intervals. There is a function "floor(x)" which return the largest integer not greater than its argument. So function floor(x/dx)*dx will map x into one of the intervals [-n*dx:-(n-1)*dx],[-(n-1)*dx:-(n-2)*dx]...[(n-1)*dx:n*dx]. &lt;br /&gt;&lt;br /&gt;Now we come to count the data number in each interval. In gnuplot there is a smooth option called "frequency". It makes the data monotonic in x. Points with the same x-value are replaced by a single point having the summed y-values. Using this property, we can count the data numbers in the intervals.&lt;br /&gt;&lt;br /&gt;At last we plot our result using boxes plot style.&lt;br /&gt;&lt;br /&gt;The main idea have introduced. It is time to write the plotting script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;n=100	#number of intervals&lt;br /&gt;max=3.	#max value&lt;br /&gt;min=-3.	#min value&lt;br /&gt;width=(max-min)/n	#interval width&lt;br /&gt;#function used to map a value to the intervals&lt;br /&gt;hist(x,width)=width*floor(x/width)+width/2.0&lt;br /&gt;set term png	#output terminal and file&lt;br /&gt;set output "histogram.png"&lt;br /&gt;set xrange [min:max]&lt;br /&gt;set yrange [0:]&lt;br /&gt;#to put an empty boundary around the&lt;br /&gt;#data inside an autoscaled graph.&lt;br /&gt;set offset graph 0.05,0.05,0.05,0.0&lt;br /&gt;set xtics min,(max-min)/5,max&lt;br /&gt;set boxwidth width*0.9&lt;br /&gt;set style fill solid 0.5	#fillstyle&lt;br /&gt;set tics out nomirror&lt;br /&gt;set xlabel "x"&lt;br /&gt;set ylabel "Frequency"&lt;br /&gt;#count and plot&lt;br /&gt;plot "data.dat" u (hist($1,width)):(1.0) smooth freq w boxes lc rgb"green" notitle&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;We use a data file (&lt;a href="https://docs.google.com/leaf?id=0B5wSAiwiTq4gZTU4NDI3ZjgtMTBmYS00NzA3LTk1NTktZWUxYjFlMTIwMmVl&amp;amp;hl=zh_CN"&gt;download from here&lt;/a&gt;) which contains 10000 normal distributed random number and get a graph like follows.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-xQNpw491eJU/Tmy3hhiQFAI/AAAAAAAAAE8/9eRzKZNvfCc/s1600/histogram.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-xQNpw491eJU/Tmy3hhiQFAI/AAAAAAAAAE8/9eRzKZNvfCc/s320/histogram.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;statistic histogram plotting using gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-876642733768123608?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/876642733768123608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-and-histogram.html#comment-form' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/876642733768123608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/876642733768123608'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-and-histogram.html' title='Statistic analysis and histogram plotting using gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-xQNpw491eJU/Tmy3hhiQFAI/AAAAAAAAAE8/9eRzKZNvfCc/s72-c/histogram.png' height='72' width='72'/><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6474673401894793281</id><published>2011-09-09T23:56:00.000-07:00</published><updated>2011-09-09T23:56:55.906-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data manipulation'/><title type='text'>Manipulate data using ternary operator in gunplot</title><content type='html'>In gnuplot there is an operator "? :" which is ternary. It behaves as it does in C language. For example, "a?b:c" means if a is true then return 'b', otherwise return 'c'. Using this operator we can do some complex operation on input data. Let us see an example.&lt;br /&gt;&lt;br /&gt;We have a data file as follows:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#x  y1   y2&lt;br /&gt;0.1	0.2	0.2&lt;br /&gt;0.2	0.4	0.4&lt;br /&gt;0.3	0.6	0.6&lt;br /&gt;0.4	0.8	0.8&lt;br /&gt;0.5	1	1&lt;br /&gt;0.6	1.2	1.2&lt;br /&gt;0.7	1.4	1.4&lt;br /&gt;0.8	2.4	0.6&lt;br /&gt;0.9	2.7	0.675&lt;br /&gt;1	3	0.75&lt;br /&gt;1.1	3.3	0.825&lt;br /&gt;1.2	3.6	0.9&lt;br /&gt;1.3	3.9	0.975&lt;br /&gt;1.4	4.2	1.05&lt;br /&gt;1.5	4.5	1.125&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;We want to plot the points y1=y2 with blue pints, and other points y1!=y2 (y1 not equals y2) with some other colors. To realize this goal, we can use ternary operator. According to the definition of ternary operator, expression "$2==$3?$2:1/0" will return the points satisfy $2=$3, and when $2!=$3 it returns undefied value(1/0 is an undefied value). So when we use command "plot 'data.dat' u 1:($2==$3?$2:1/0) w p", we plot the points with y1=y2. In a simillar manner, we can plot the points with y1!=y2. Now we come to our final plotting script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png font "Times,20"&lt;br /&gt;set output "ternaty.png"&lt;br /&gt;set xlabel "x"&lt;br /&gt;set ylabel "y"&lt;br /&gt;plot "data.dat" u 1:($2==$3?$2:1/0) w p lc rgb"blue" notitle,\&lt;br /&gt;     "data.dat" u 1:($2!=$3?$2:1/0) w p lc rgb"green" notitle,\&lt;br /&gt;     "data.dat" u 1:($2!=$3?$3:1/0) w p lc rgb"red" notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The picture comes out to be like follows.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-kl8iRkmtmOY/TmsJ3TfN_iI/AAAAAAAAAE4/tZH8SaDdAII/s1600/ternaty.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-kl8iRkmtmOY/TmsJ3TfN_iI/AAAAAAAAAE4/tZH8SaDdAII/s320/ternaty.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Manipulate data using ternary operator in gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6474673401894793281?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6474673401894793281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/manipulate-data-using-ternary-operator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6474673401894793281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6474673401894793281'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/manipulate-data-using-ternary-operator.html' title='Manipulate data using ternary operator in gunplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-kl8iRkmtmOY/TmsJ3TfN_iI/AAAAAAAAAE4/tZH8SaDdAII/s72-c/ternaty.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-5983315410925305670</id><published>2011-09-09T23:33:00.000-07:00</published><updated>2011-09-09T23:48:18.935-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gradient color'/><title type='text'>Gradient colored curve in Gnuplot(2)</title><content type='html'>In the previous article we plot a gradient colored curve by expanding it to a 3-d surface and view the surface in a particular viewpoint. Today we talk about a third method.&lt;br /&gt;&lt;br /&gt;In gnuplot we can specify the plotting colors by "rgbcolor variable". It can assign a separate color for each data point,line segment,or label based on additional  information in the input data file. For example "plot 'data.dat' u 1:2:3 with points lc rgb variable" will plot each data point with separate color according to the third column of the data file. Now we come to plot the following data file using "rgbcolor variable".&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;0.0 	0.00 &lt;br /&gt;0.2 	0.14 &lt;br /&gt;0.4 	0.56 &lt;br /&gt;0.6 	1.25 &lt;br /&gt;0.8 	2.12 &lt;br /&gt;1.0 	3.00 &lt;br /&gt;1.2 	3.65 &lt;br /&gt;1.4 	3.90 &lt;br /&gt;1.6 	3.79 &lt;br /&gt;1.8 	3.64 &lt;br /&gt;2.0 	4.00 &lt;br /&gt;2.2 	5.40 &lt;br /&gt;2.4 	8.10 &lt;br /&gt;2.6 	11.84 &lt;br /&gt;2.8 	15.84 &lt;br /&gt;3.0 	19.00 &lt;br /&gt;3.2 	20.41 &lt;br /&gt;3.4 	19.78 &lt;br /&gt;3.6 	17.78 &lt;br /&gt;3.8 	15.91 &lt;br /&gt;4.0 	16.00 &lt;br /&gt;4.2 	19.42 &lt;br /&gt;4.4 	26.39 &lt;br /&gt;4.6 	35.66 &lt;br /&gt;4.8 	44.78 &lt;br /&gt;5.0 	51.00 &lt;br /&gt;5.2 	52.40 &lt;br /&gt;5.4 	48.90 &lt;br /&gt;5.6 	42.54 &lt;br /&gt;5.8 	36.95 &lt;br /&gt;6.0 	36.00 &lt;br /&gt;6.2 	42.21 &lt;br /&gt;6.4 	55.46 &lt;br /&gt;6.6 	72.72 &lt;br /&gt;6.8 	88.97 &lt;br /&gt;7.0 	99.00 &lt;br /&gt;7.2 	99.63 &lt;br /&gt;7.4 	91.26 &lt;br /&gt;7.6 	78.06 &lt;br /&gt;7.8 	66.75 &lt;br /&gt;8.0 	64.00 &lt;br /&gt;8.2 	73.76 &lt;br /&gt;8.4 	95.28 &lt;br /&gt;8.6 	123.02 &lt;br /&gt;8.8 	148.39 &lt;br /&gt;9.0 	163.00 &lt;br /&gt;9.2 	162.10 &lt;br /&gt;9.4 	146.85 &lt;br /&gt;9.6 	124.35 &lt;br /&gt;9.8 	105.31 &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Our plotting script is:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;plot "data.dat" #To get the max and min vaule&lt;br /&gt;MAX=GPVAL_Y_MAX&lt;br /&gt;MIN=GPVAL_Y_MIN&lt;br /&gt;LEN=MAX-MIN&lt;br /&gt;set term png&lt;br /&gt;set output "gradient_colored_curve3.png"&lt;br /&gt;set key off&lt;br /&gt;plot "data.dat" w l lw 2 lc rgb"green" smooth csplines, \&lt;br /&gt;     "data.dat" u 1:2:(255-($2-MIN)/LEN*255) w p pt 7 \&lt;br /&gt;     ps 2 lc rgb variable notitle&lt;br /&gt;#(255-($2-MIN)/LEN*255) means when data vary from min&lt;br /&gt;#to max, color vary from blue to black&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;It is a simple and good method. But it is hard for us to design a beautiful color palette. This is its disadvantage.&lt;br /&gt;&lt;br /&gt;At last is what does the picture gradient_colored_curve3.png looks like.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-CsJ8fCf7PYI/TmsEiHkNHzI/AAAAAAAAAE0/2zeNIDQEL-M/s1600/gradient_colored_curve3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-CsJ8fCf7PYI/TmsEiHkNHzI/AAAAAAAAAE0/2zeNIDQEL-M/s320/gradient_colored_curve3.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gradient colored curve plotted by gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-5983315410925305670?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/5983315410925305670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5983315410925305670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/5983315410925305670'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot2.html' title='Gradient colored curve in Gnuplot(2)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-CsJ8fCf7PYI/TmsEiHkNHzI/AAAAAAAAAE0/2zeNIDQEL-M/s72-c/gradient_colored_curve3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-867499270665380967</id><published>2011-09-09T05:10:00.000-07:00</published><updated>2011-09-09T23:48:07.415-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gradient color'/><title type='text'>Gradient colored curve in Gnuplot(1)</title><content type='html'>Last time we talked about how to draw a gradient colored curve. We realized it by cutting the total curve into n segment and plot the n segment using different colors. This time we talk about another method.&lt;br /&gt;&lt;br /&gt;We know that at a special viewpoint a surface can appear like a line. We also know that gunplot can plot colored surface with pm3d plotting style. So we may expand our line to a surface. Plot the surface with pm3d. View it in a special viewpoint. Now we come to realize our idea.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "gradient_colored_curve2.png"&lt;br /&gt;set isosample 200,2 &lt;br /&gt;#As along y-axis the surface has a constant value,&lt;br /&gt;#the samples along y-axis can set to be a small value.&lt;br /&gt;set palette rgbformulae 7,5,15&lt;br /&gt;unset colorbox&lt;br /&gt;set xyplane relative 0&lt;br /&gt;set xtics offset 0,-1   &lt;br /&gt;#putting xtics label 1 character lower makes the plotting nicer&lt;br /&gt;unset ytics #ytics is not necessary&lt;br /&gt;unset border #the border will plot manually&lt;br /&gt;#plot axes manually&lt;br /&gt;set arrow 1 from graph 0,0,0 to graph 1.1,0,0&lt;br /&gt;set arrow 2 from graph 0,0,0 to graph 0,0,1.1&lt;br /&gt;#plot xtics manually&lt;br /&gt;set for [i=-10:10:5] arrow from i,0,-1.0 to i,0,-0.95 nohead&lt;br /&gt;set view 89.5,0 #map the 3-d surface to coordinate plane&lt;br /&gt;splot sin(x) w pm3d notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Note that the view should be set to a value near "90,0" but not exactly "90,0" (if view exactly equals "90,0", "linwidth" of the curve is 0), here we choose "89.5,0".  Compared to the previous one, this method takes less time. The output picture file is shown below.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-F3yqILiKeBc/TmoBgGCeJII/AAAAAAAAAEw/svG91bCpUxw/s1600/gradient_colored_curve2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-F3yqILiKeBc/TmoBgGCeJII/AAAAAAAAAEw/svG91bCpUxw/s320/gradient_colored_curve2.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gradient colored curve plotted by gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-867499270665380967?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/867499270665380967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/867499270665380967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/867499270665380967'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot1.html' title='Gradient colored curve in Gnuplot(1)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-F3yqILiKeBc/TmoBgGCeJII/AAAAAAAAAEw/svG91bCpUxw/s72-c/gradient_colored_curve2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6560726177095281349</id><published>2011-09-07T04:59:00.000-07:00</published><updated>2011-09-09T23:47:53.172-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gradient color'/><title type='text'>Gradient colored curve in Gnuplot(0)</title><content type='html'>A friend of mine asked me:"How can we plot a figure like this one (the following one) using gnuplot?"&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-yeuiYfP6IXg/TmdYz-b4ecI/AAAAAAAAAEk/yqrESPny69I/s1600/gradient_colored_curve1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-yeuiYfP6IXg/TmdYz-b4ecI/AAAAAAAAAEk/yqrESPny69I/s320/gradient_colored_curve1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gradient colored curve&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;It is a bit hard. We know that command&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;plot function-or-datafile with lines linecolor rgb"rgb-color"&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;can plot a curve with specific color, but the color can not vary along the curve. How to deal with this kind of picture? I thought for a while and answered:"I have three different methods. Let me tell you one by one, and you can select the one which you like most." &lt;br /&gt;&lt;br /&gt;Today I will introduce my first method.&lt;br /&gt;&lt;br /&gt;The idea is simply cutting the curve into n segments, and plot these n sub-curves with different colors. It is realized by the following gnuplot script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "gradient_colored_curve1.png"&lt;br /&gt;f(x)=exp(-0.33*x)*sin(5*pi*x)   #The function to be plotted&lt;br /&gt;n=100   #divide the whole curve into n segments&lt;br /&gt;set samples 300 #must be large enough for each segment have at least 2 samples&lt;br /&gt;set palette rgbformulae 30,13,10    #rainbow palette&lt;br /&gt;set cbrange [0:n]&lt;br /&gt;set xrange [0:10]&lt;br /&gt;unset colorbox  #The colorbox will not plotted&lt;br /&gt;#Plot the n segments of the curve&lt;br /&gt;plot for [i=0:n] i&amp;lt;=x*n/10 &amp;amp;&amp;amp; x*n/10&amp;lt;(i+1.5) ?f(x):1/0 \&lt;br /&gt;     w l lw 2 lc palette cb i notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In the script it is "i+1.5" not "i+1", because we want two segments close to each other have a common part. In such a way the boundary between them will not so obvious. And be sure that the samples should be set to a value large enough for each small segment have at least 2 samples. The advantage of this method is its simplicity. The disadvantage is that since this script will plot for n times, it will take a very long time (on my computer about 1 second). This script just produce a picture the same as the one my friend shown me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6560726177095281349?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6560726177095281349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot0.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6560726177095281349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6560726177095281349'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot0.html' title='Gradient colored curve in Gnuplot(0)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-yeuiYfP6IXg/TmdYz-b4ecI/AAAAAAAAAEk/yqrESPny69I/s72-c/gradient_colored_curve1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6780218728928832073</id><published>2011-09-04T03:46:00.000-07:00</published><updated>2011-10-03T07:39:01.198-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shadow'/><category scheme='http://www.blogger.com/atom/ns#' term='legend'/><category scheme='http://www.blogger.com/atom/ns#' term='key'/><title type='text'>Shadow to the key in Gnuplot</title><content type='html'>Yesterday we talk about &lt;a href="http://gnuplot-surprising.blogspot.com/2011/09/shadow-to-curve-in-gnuplot.html"&gt;shadow to a curve in gnuplot&lt;/a&gt; . But the key is not plotted. Now we come to add a shadowed key to our graph. The method is the same as before, plotting the objects two or more times.  The following is an example gnuplot script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "shadowkey.png"&lt;br /&gt;dy=0.75&lt;br /&gt;angle=pi/6.0&lt;br /&gt;dx=dy*tan(angle)&lt;br /&gt;f(x)=0.1*(x-10)*x*(x+10)&lt;br /&gt;set object 1 rectangle from graph 0.91,0.89 \&lt;br /&gt;    to graph 0.66,0.74 fillstyle solid 1.0 noborder \&lt;br /&gt;    fc rgb"#cccccc"	#key-box shadow&lt;br /&gt;set object 2 rectangle from graph 0.9,0.9 \&lt;br /&gt;    to graph 0.65,0.75 fc rgb"#ffffff"    #key-box&lt;br /&gt;set arrow 1 lw 7 lc rgb"#cccccc" from graph 0.78,0.82 \&lt;br /&gt;    to graph 0.86,0.82 nohead #samle-line shadow&lt;br /&gt;set arrow 2 lw 7 lc rgb"red" from graph 0.77,0.83 \&lt;br /&gt;    to graph 0.85,0.83 nohead     #sample-line&lt;br /&gt;set label 1 "f(x)" at graph 0.7,0.83	#key label&lt;br /&gt;set xrange [-15:15]&lt;br /&gt;plot f(x-dx)-dy w l lw 7 lc rgb"#cccccc" notitle,\&lt;br /&gt;     f(x) w l lw 7 lc rgb"red" notitle&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Because gnuplot can not give us enough control on the key by using command "set key ...", in this script we draw the key manually using rectangles,arrows and label. The final appearance of shadow1.png is shown below.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-IPuoamvH854/TmNVsTYsYmI/AAAAAAAAADc/3qPYbIbv34k/s1600/shadowkey.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-IPuoamvH854/TmNVsTYsYmI/AAAAAAAAADc/3qPYbIbv34k/s320/shadowkey.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Shadow to the key in gnuplot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6780218728928832073?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6780218728928832073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/shadow-to-key-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6780218728928832073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6780218728928832073'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/shadow-to-key-in-gnuplot.html' title='Shadow to the key in Gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-IPuoamvH854/TmNVsTYsYmI/AAAAAAAAADc/3qPYbIbv34k/s72-c/shadowkey.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-7193304883994015008</id><published>2011-09-03T03:47:00.000-07:00</published><updated>2011-09-03T03:48:03.213-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shadow'/><title type='text'>Shadow to a curve in Gnuplot</title><content type='html'>Adding shadow to a curve or some other objects can makes a 2-d plot looks like a 3-d one. The common way producing a shadow effect is drawing the object two times. Now let us come to an example of shadowing to a curve.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "shadow1.png"&lt;br /&gt;dy=0.75&lt;br /&gt;dx=dy*tan(pi/6)&lt;br /&gt;f(x)=0.1*(x-10)*x*(x+10)&lt;br /&gt;set xrange [-15:15]&lt;br /&gt;plot f(x-dx)-dy w l lw 7 lc rgb"#cccccc" notitle,\&lt;br /&gt;      f(x) w l lw 7 lc rgb"red" notitle&lt;/pre&gt;&lt;/div&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-FeMb1VQlzwk/TmIC3wC9u8I/AAAAAAAAADU/drtaCg2jjic/s1600/shadow1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-FeMb1VQlzwk/TmIC3wC9u8I/AAAAAAAAADU/drtaCg2jjic/s320/shadow1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Simple shadow effect&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Firstly the shadow offset along y-axis and x-axis are given.  The earlier plot is used to produce the shadow effcet and the later one is the data plotting. Note that the data plotting must be put after the shadow plotting, otherwise the "shadow" may cloud the data-curve. From the picture we find that the shadow effect have been realized, but it seems that the shadow is too sharp. We need to improve the script to get a better effect. Now let us do this. Our main idea is plotting the shadow sevral times with diffrent scale of gray colors. We realize this idea using a "for" iteration. The following is our improved script and the corresponding graph.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "shadow2.png"&lt;br /&gt;dy=0.75&lt;br /&gt;dx=dy*tan(pi/6)&lt;br /&gt;levels=15&lt;br /&gt;f(x)=0.1*(x-10)*x*(x+10)&lt;br /&gt;set palette gray&lt;br /&gt;set cbrange [0:1]&lt;br /&gt;unset colorbox&lt;br /&gt;set xrange [-15:15]&lt;br /&gt;set yrange [-200:200]&lt;br /&gt;set multiplot&lt;br /&gt;plot for [i=levels:1:-1] f(x-i*(1.0/levels)*dx)-i*(1.0/levels)*dy w l lw 7 \&lt;br /&gt;      lc palette cb i*(0.5/levels)+0.35 notitle&lt;br /&gt;plot f(x) w l lw 7 lc rgb"red" notitle&lt;br /&gt;unset multiplot&lt;/pre&gt;&lt;/div&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-5MYiySlVju4/TmIEubF_33I/AAAAAAAAADY/bEm4-Qe4u6k/s1600/shadow2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-5MYiySlVju4/TmIEubF_33I/AAAAAAAAADY/bEm4-Qe4u6k/s320/shadow2.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Improved shadow effect&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-7193304883994015008?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/7193304883994015008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/shadow-to-curve-in-gnuplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7193304883994015008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7193304883994015008'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/shadow-to-curve-in-gnuplot.html' title='Shadow to a curve in Gnuplot'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-FeMb1VQlzwk/TmIC3wC9u8I/AAAAAAAAADU/drtaCg2jjic/s72-c/shadow1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-6870875212042545223</id><published>2011-09-02T06:43:00.000-07:00</published><updated>2012-02-29T02:28:01.819-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><title type='text'>Gnuplot background image</title><content type='html'>Gnuplot can read png binary file and then plot it on the canvas. Using this utility we can add a background image to our plot. Let us see an example script.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set term png&lt;br /&gt;set output "world_population.png"&lt;br /&gt;set multiplot&lt;br /&gt;set xrange [0:799] &lt;br /&gt;set yrange [0:409]&lt;br /&gt;#As the background picture's size is 800x410,&lt;br /&gt;#we choose xrange and yrange of these values&lt;br /&gt;unset tics&lt;br /&gt;unset border&lt;br /&gt;set lmargin at screen 0.175&lt;br /&gt;set rmargin at screen 0.9&lt;br /&gt;set bmargin at screen 0.15&lt;br /&gt;set tmargin at screen 0.9&lt;br /&gt;#Plot the background image&lt;br /&gt;plot "map.png" binary filetype=png w rgbimage&lt;br /&gt;#The x and y range of the population data file&lt;br /&gt;set xrange [1740:2020]&lt;br /&gt;set yrange [0:7000]&lt;br /&gt;set border&lt;br /&gt;set tics out nomirror scale 2&lt;br /&gt;set mxtics 5&lt;br /&gt;set key left&lt;br /&gt;set xlabel "Year"&lt;br /&gt;set ylabel "Population(in millions)"&lt;br /&gt;plot "population.dat" u 1:2 w lp lw 2 ps 1 pt 7 title "world",\&lt;br /&gt;     "population.dat" u 1:3 w lp lw 2 ps 1 pt 7 title "Africa",\&lt;br /&gt;     "population.dat" u 1:4 w lp lw 2 ps 1 pt 7 title "Asia",\&lt;br /&gt;     "population.dat" u 1:5 w lp lw 2 ps 1 pt 7 title "Europe",\&lt;br /&gt;     "population.dat" u 1:6 w lp lw 2 ps 1 pt 7 title "Katub America",\&lt;br /&gt;     "population.dat" u 1:7 w lp lw 2 ps 1 pt 7 title "Northern America",\&lt;br /&gt;     "population.dat" u 1:8 w lp lw 2 ps 1 pt 7 title "Oceania"&lt;br /&gt;unset multiplot&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In this script, map.png is our background image with size 800x410 (That is why we choose xrange and yrange to be 0-799 and 0-409 respectively). population.dat is a file containing information of world population from 0 AD to 2000 AD. The first plot command is used to plot the background image, while the second plot command is used to plot our world population data file. To make these two plot coincide with each other, l,r,t,bmargin are set in the screen coordinate. The data file is as follows:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;#Data from http://en.wikipedia.org/wiki/World_population&lt;br /&gt;#Year  World  Africa  Asia  Europe  Latin America  Northern America  Oceania&lt;br /&gt;1750  791  106  502  163  16  2  2  &lt;br /&gt;1800  978  107  635  203  24  7  2  &lt;br /&gt;1850  1262  111  809  276  38  26  2  &lt;br /&gt;1900  1650  133  947  408  74  82  6  &lt;br /&gt;1950  2519  221  1398  547  167  172  12.8  &lt;br /&gt;1955  2756  247  1542  575  191  187  14.3  &lt;br /&gt;1960  2982  277  1674  601  209  204  15.9  &lt;br /&gt;1965  3335  314  1899  634  250  219  17.6  &lt;br /&gt;1970  3692  357  2143  656  285  232  19.4  &lt;br /&gt;1975  4068  408  2397  675  322  243  21.5  &lt;br /&gt;1980  4435  470  2632  692  361  256  22.8  &lt;br /&gt;1985  4831  542  2887  706  401  269  24.7  &lt;br /&gt;1990  5263  622  3168  721  441  283  26.7  &lt;br /&gt;1995  5674  707  3430  727  481  299  28.9  &lt;br /&gt;2000  6070  796  3680  728  520  316  31.0  &lt;br /&gt;2005  6454  888  3917  725  558  332  32.9  &lt;br /&gt;2008  6707  973  4054  732  577  337  34.3&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;To use background image file of format other than png, we shold first convert it to a png file. This task can be done well using ImageMagick.&lt;br /&gt;&lt;br /&gt;At last, this is the picture file world_population.png produced by the plotting script.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-wRaDRkj9j7Q/TmDdCQy0dPI/AAAAAAAAADQ/EAmSiATLv3I/s1600/world_population.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-wRaDRkj9j7Q/TmDdCQy0dPI/AAAAAAAAADQ/EAmSiATLv3I/s320/world_population.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gnuplot background image&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-6870875212042545223?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/6870875212042545223/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gnuplot-background-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6870875212042545223'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/6870875212042545223'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/gnuplot-background-image.html' title='Gnuplot background image'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-wRaDRkj9j7Q/TmDdCQy0dPI/AAAAAAAAADQ/EAmSiATLv3I/s72-c/world_population.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-4887428835826247792</id><published>2011-09-01T19:15:00.000-07:00</published><updated>2011-09-03T03:20:34.800-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gradient color'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><title type='text'>Gnuplot advanced background color (1)</title><content type='html'>An alternative way to realize a linear gradient colored background is using the image plotting style. Let us first look at our final script and then explain it.&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;set table "back.dat"	#creat a data file&lt;br /&gt;set isosample 2,200	#containing linear&lt;br /&gt;splot y			#gradient color &lt;br /&gt;unset table		#information&lt;br /&gt;&lt;br /&gt;splot y	#Get the max value of z&lt;br /&gt;max=GPVAL_Z_MAX&lt;br /&gt;&lt;br /&gt;set term png&lt;br /&gt;set output "backgradient2.png"&lt;br /&gt;set multiplot&lt;br /&gt;#plot the background&lt;br /&gt;set lmargin at screen 0&lt;br /&gt;set rmargin at screen 1&lt;br /&gt;set bmargin at screen 0&lt;br /&gt;set tmargin at screen 1&lt;br /&gt;unset border&lt;br /&gt;unset tics&lt;br /&gt;set palette defined(0"white",max"#ccffcc")  #set gradient color&lt;br /&gt;plot "back.dat" w ima&lt;br /&gt;#plot the curve of sin(x)&lt;br /&gt;set border 1+2+4+8&lt;br /&gt;set tics&lt;br /&gt;set lmargin&lt;br /&gt;set rmargin&lt;br /&gt;set bmargin&lt;br /&gt;set tmargin&lt;br /&gt;plot sin(x) w l lw 2 lc rgb"black" notitle&lt;br /&gt;unset multiplot&lt;br /&gt;!del back.dat&lt;br /&gt;#in unix system the above command may should be change to "!rm back.dat"&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In this script, firstly we produce a date file "back.dat" which contain linear gradient color information. Then in a multiplot environment we plot the background using command '''plot "back.dat" w ima''' and figure of sin(x) using '''plot sin(x) w l lw 2 lc rgb"black" notitle'''. Before plotting the background we set l,r,b,tmargin to be 0,1,0,1 respectively, thus the background is filled the whole picture, and border and tics are unset. After that all of border,margins and tics are set again. "! del back.dat" is used to delete temporary data file back.dat. backgradient2.png is show below:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-EpyBIJeB9IA/TmA7ghSX8CI/AAAAAAAAADM/udhPbZSycaE/s1600/backgradient2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-EpyBIJeB9IA/TmA7ghSX8CI/AAAAAAAAADM/udhPbZSycaE/s320/backgradient2.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Linear gradient colored background&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-4887428835826247792?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/4887428835826247792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/advanced-background-color-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/4887428835826247792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/4887428835826247792'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/09/advanced-background-color-1.html' title='Gnuplot advanced background color (1)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-EpyBIJeB9IA/TmA7ghSX8CI/AAAAAAAAADM/udhPbZSycaE/s72-c/backgradient2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-7888462353822437852</id><published>2011-08-31T21:52:00.000-07:00</published><updated>2011-09-03T03:20:22.647-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gradient color'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><title type='text'>Gnuplot advanced background color (0)</title><content type='html'>It is not so hard to plot a single color background graph using gnuplot, and we have done this in blog ---- &lt;a href="http://gnuplot-surprising.blogspot.com/2011/08/simple-background-color.html"&gt;simple background color&lt;/a&gt;. But how about a linear gradient colored background? &lt;br /&gt;&lt;br /&gt;The fill color of a object can not be set to be gradient in gnuplot. So the method in simple background color can not be copied, at least can not be  copied directly. But if we draw a set&lt;br /&gt;of small rectangles with different color, it may have the same appearence as a large rectangle with linear gradient color. Now let us realize this idea. &lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;reset&lt;br /&gt;n=200   #number of rectangles&lt;br /&gt;dx=1.0/n    #legth of rectangle&lt;br /&gt;set palette defined(0"white",n"#ccffcc")  #set gradient color&lt;br /&gt;set cbrange [0:n]&lt;br /&gt;unset colorbox&lt;br /&gt;set for [i=1:n] object i rectangle from screen (i-1)*dx,0 to \&lt;br /&gt;screen i*dx+dx/2,1 fs solid 1.0 noborder fillcolor palette cb i \&lt;br /&gt;behind&lt;br /&gt;#draw a set of rectangle with diffrent color."+dx/2" makes the&lt;br /&gt;#adjacent rectangles have a common part, so that the border is not&lt;br /&gt;#so obvious&lt;br /&gt;set term png&lt;br /&gt;set output "backgradient1.png"&lt;br /&gt;plot sin(x) w l lw 0 lc palette cb 0 notitle,sin(x) w l lw 2 lc \&lt;br /&gt;rgb"blue" notitle&lt;br /&gt;#The first plot is just used to enable the palette, and it will be&lt;br /&gt;#covered by the second plot never appearing on the output picture.&lt;br /&gt;set output&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;And the above commands produce the following graph:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-7dhzYLWDroQ/Tl8MOV4IW3I/AAAAAAAAADI/ft2nRAsSzRI/s1600/backgradient1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-7dhzYLWDroQ/Tl8MOV4IW3I/AAAAAAAAADI/ft2nRAsSzRI/s320/backgradient1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Linear gradient colored background&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-7888462353822437852?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/7888462353822437852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/08/advanced-background-color-0.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7888462353822437852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/7888462353822437852'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/08/advanced-background-color-0.html' title='Gnuplot advanced background color (0)'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-7dhzYLWDroQ/Tl8MOV4IW3I/AAAAAAAAADI/ft2nRAsSzRI/s72-c/backgradient1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8684207873816623164.post-8675761275719431761</id><published>2011-08-30T22:19:00.000-07:00</published><updated>2011-09-03T03:20:08.434-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='background'/><title type='text'>Gnuplot simple background color</title><content type='html'>By default gnuplot will produce graphes with white background color. We can change it by drawing a colored rectangle at the lowest layer:&lt;br /&gt;&lt;div class="codes"&gt;&lt;pre&gt;set object &amp;lt;index_number&amp;gt; rectangle \&lt;br /&gt;         from screen 0,0 to screen 1,1 fillcolor rgb"&amp;lt;rgb-color&amp;gt;" behind &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;In this command line, &amp;lt;index_number&amp;gt; is used to mark the rectangle object, if we want to change the background color later it will be usefull, "from screen 0,0 to screen 1,1" means the rectangle is as large as the whole picture, &amp;lt;rgb-color&amp;gt; is the background color and "behind" put the rectangle behind all other elements of the picture，i.e., the lowest layer.&lt;br /&gt;&lt;br /&gt;Now let's have a look at an example script which produce two graphes with pink and light green background color respectively.&lt;br /&gt;&lt;div class=codes&gt;&lt;pre&gt;reset #reset gnuplot options&lt;br /&gt;set term png font ",22" linewidth 3  #set terminal to png with fontsize=22,linewidth=3&lt;br /&gt;set xlabel "x"  #set xlable and ylabel&lt;br /&gt;set ylabel "y=sin(x)"&lt;br /&gt;#set a pink(#ffcccc) background color&lt;br /&gt;set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#ffcccc" behind&lt;br /&gt;set output "pink.png"&lt;br /&gt;plot sin(x) with lines linecolor rgb"green" notitle&lt;br /&gt;#set a light green(#ccffcc) background color&lt;br /&gt;set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#ccffcc" behind&lt;br /&gt;set output "lightgreen.png"&lt;br /&gt;plot sin(x) with lines linecolor rgb"red" notitle&lt;/pre&gt;&lt;/div&gt;And pink.png and lightgreen.png are shown below:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-XO_dc5pvW78/Tl3Db-sk-3I/AAAAAAAAABo/FFTOYti6hhM/s1600/pink.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-XO_dc5pvW78/Tl3Db-sk-3I/AAAAAAAAABo/FFTOYti6hhM/s320/pink.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Pink background color&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-0nldiMfwJDo/Tl3pz7ccXKI/AAAAAAAAACA/LdWqDJs6NXA/s1600/lightgreen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-0nldiMfwJDo/Tl3pz7ccXKI/AAAAAAAAACA/LdWqDJs6NXA/s320/lightgreen.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Light green background color&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8684207873816623164-8675761275719431761?l=gnuplot-surprising.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gnuplot-surprising.blogspot.com/feeds/8675761275719431761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/08/simple-background-color.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8675761275719431761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8684207873816623164/posts/default/8675761275719431761'/><link rel='alternate' type='text/html' href='http://gnuplot-surprising.blogspot.com/2011/08/simple-background-color.html' title='Gnuplot simple background color'/><author><name>数声风笛离亭晚，我想潇湘君想秦！</name><uri>http://www.blogger.com/profile/08963583502168321534</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/-2zIcFJAoqfE/TmS16PL45kI/AAAAAAAAAEA/t9Ds53_u00U/s220/%25E6%259E%2597%25E9%25BB%259B%25E7%258E%2589%25EF%25BC%2588%25E9%25BB%2591%25E7%2599%25BD%25EF%25BC%2589.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-XO_dc5pvW78/Tl3Db-sk-3I/AAAAAAAAABo/FFTOYti6hhM/s72-c/pink.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
