{"id":436,"date":"2018-07-13T12:26:04","date_gmt":"2018-07-13T12:26:04","guid":{"rendered":"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=436"},"modified":"2019-05-16T09:21:12","modified_gmt":"2019-05-16T09:21:12","slug":"gnuplot","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/chapter\/gnuplot\/","title":{"rendered":"GNUPLOT"},"content":{"raw":"<div><span style=\"float: right;\"><a href=\"https:\/\/youtu.be\/O_4-4I27Ovc\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n&nbsp;\r\n\r\n<strong>Overview of GNUPLOT<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">In this module, we will learn a plotting software that is used to create 2D and 3D plots. As you are aware that there are wide range of GUI software and spreadsheet packages that help us to create graphs and plots using a graphical interface. However, if we want to use mathematical expressions to plot charts, such kind of software will be of less help to us. Plotting features are available with various software like R, Python, etc. but they require programming knowledge of these languages. In this module, we will learn an open source tool GNUPLOT that does not require programming knowledge, by writing small scripts, we can generate efficient plots that can be of 2D or 3D.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Gnuplot is an open source command-line program, it is widely used by Engineers, Scientists, Data Analysts and Educators. It is used to generate 2D and 3D plots, these plots can be generated with the help of data or by using functions and mathematical expressions. It is distributed under GNU GPL and intially released in 1986. GNUPLOT runs on major OS like Linux, Unix, Windows, MacOS etc. Gnuplot can produce output directly on screen, or in many formats of graphics files, including Portable Network Graphics (PNG), Encapsulated PostScript (EPS), Scalable Vector Graphics (SVG), JPEG and many others. It is also capable of producing LaTeX code that can be included directly in LaTeX documents. Gnuplot can be used both interactively and in batch mode using scripts<\/p>\r\n&nbsp;\r\n\r\n<strong>Installation<\/strong>\r\n<p style=\"text-align: justify;\">Gnuplot can be downloaded from the website :<a href=\"https:\/\/sourceforge.net\/projects\/gnuplot\/\">https:\/\/sourceforge.net\/projects\/gnuplot\/.<\/a>The software is available in binary form for Windows and is also available as open source or as repository for various linux distributions. We can install gnuplot for Redhat base distributions or for Ubuntu based distributions using the following command:<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-437 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1.png\" alt=\"\" width=\"642\" height=\"63\" \/>\r\n\r\n<strong>Interface of Gnuplot<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Gnuplot has its own command line interface. We can see the interface by issuing gnuplot command on $ prompt in linux. The following screen illustrates the interface of Gnuplot:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-439 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K1.jpg\" alt=\"\" width=\"1440\" height=\"759\" \/><\/p>\r\n<p style=\"text-align: center;\">Figure 1: Interface of GNUPLOT<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Gnuplot comes with its own default settings. For instance, when we plot data, it will be displayed with points and the functions are plotted with lines. There are default colors used for different functions. These default settings can be seen by issuing the following command:<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-440 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2.png\" alt=\"\" width=\"631\" height=\"34\" \/><\/p>\r\n<p style=\"text-align: justify;\">There is always a default working directory associated so that the scripts can be read from the default directory. This default directory can be displayed using the following pwd command. The following screen shows output of \u201cpwd\u201d and \u201cshow style\u201d commands:<\/p>\r\n.<img class=\"size-full wp-image-441 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K2.jpg\" alt=\"\" width=\"1440\" height=\"672\" \/>\r\n<p style=\"text-align: center;\">Figure 2: Output of pwd and show style commands<\/p>\r\n&nbsp;\r\n\r\n<strong>Plotting functions<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">We can plot mathematical expressions and functions using gnuplot. For single function, we can simply call the function from command prompt. However, if we want to configure the output in desired format, there is a facility of writing scripts to configure the details of the output. Let us explore the commands and its related output using the gnuplot software.<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-442 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K3.png\" alt=\"\" width=\"659\" height=\"291\" \/><\/p>\r\n<img class=\"alignnone size-full wp-image-443 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K4.png\" alt=\"\" width=\"575\" height=\"512\" \/>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-444 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K5.png\" alt=\"\" width=\"580\" height=\"254\" \/><\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-445 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K6.png\" alt=\"\" width=\"543\" height=\"483\" \/><\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-446 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K7.png\" alt=\"\" width=\"575\" height=\"270\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Writing Scripts<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">When we want to plot a more customization plot where different functions can be shown with different colors and styles, we write small scripts to manage desirable plots. In the following script, we have configured the border style, line style and titles. We have used two plots, each represented by f(x) and g(x) functions.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-447 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K8.png\" alt=\"\" width=\"537\" height=\"235\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">The output of above mentioned script is shown in figure 10. It must be noted that in the output, we have given title to f(x) plot and the linestyle is distinct from that of g(x) plot.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-448 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K9.png\" alt=\"\" width=\"418\" height=\"328\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Plotting data from file<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">We can plot data residing in file using gnuplot software. Let us seen an example of ploting some sample data where the data is used from a file. In the following example, our data is stored in a file \u201cdata1.dat\u201d. By issuing the following command, the data will be displayed in the desired line format. The output of the command is shown in figure 12 and the data is shown in figure 11.<\/p>\r\n<img class=\"alignnone size-full wp-image-449 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K10.png\" alt=\"\" width=\"579\" height=\"295\" \/>\r\n<p style=\"text-align: justify;\">While plotting data from a file, the data must be in columnar format as shown in above figure. We must also take care that the comments are used with a # sign.<\/p>\r\n&nbsp;\r\n\r\n<strong>Plotting Histogram<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Let us see an example where we plot a histogram using the gnuplot software. Although various types of charts can be plot, we will see a sample example of plotting histogram from some data file.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-450 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K11.png\" alt=\"\" width=\"584\" height=\"187\" \/><\/p>\r\n<p style=\"text-align: justify;\">Using the above script, we have plot a histogram as shown in figure 14. The histogram is plotted using data from \u201cdata.dat\u201d file. The content of data file is shown in figure 13. As you can observe in the script, we have made labeling of x-axis in customized format. In the above script, we have used labels of x-axis as one of the columns that is the date. When we plot the histogram, the data is chosen from columns 2 to columns 4 and the labels are taken from column 1. These details are mentioned using the plot command. As shown in the script, the plot command takes filename, and labels of x-axis to generate the histogram.<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-451 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1.png\" alt=\"\" width=\"584\" height=\"187\" \/><\/p>\r\n<p style=\"text-align: justify;\">A variety of 2D and 3D plots can be generated using the gnuplot tool. There is a dedicated website that demonstrates different plots, the website <a href=\"http:\/\/www.gnuplot.info\/\">www.gnuplot.info <\/a>lists many scripts and their corresponding plots. Gnuplot can be integrated with other software like Latex, Octave, etc. to generate plots with the software environment.<\/p>\r\nLet us summarize the key concepts covered in this module\r\n<ul>\r\n \t<li>Overview of Gnuplot<\/li>\r\n \t<li>Plotting functions<\/li>\r\n \t<li>Modifying styles while plotting<\/li>\r\n \t<li>Plotting from data file<\/li>\r\n \t<li>Plotting a histogram using script<\/li>\r\n<\/ul>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on GNUPLOT<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/O_4-4I27Ovc\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<strong>References for GNUPLOT:<\/strong>\r\n<ol>\r\n \t<li style=\"text-align: justify;\">GNUPlot Home Page. http:\/\/gnuplot.info\/<\/li>\r\n \t<li style=\"text-align: justify;\">Lee. Philipps. 2012. <em>Gnuplot cookbook\u202f: over 80 recipes to visually explore the full<\/em> <em>range of features of the world\u2019s preeminent open source graphing system<\/em>, Packt Publishing.<\/li>\r\n \t<li style=\"text-align: justify;\">Jeroen Janssens. <em>Data science at the command line<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Thomas Williams and Colin Kelley. 2015. <em>Gnuplot 5.0 Reference manual<\/em>, Samurai Media Limited.<\/li>\r\n \t<li style=\"text-align: justify;\">Philipp K. Janert. <em>Gnuplot in action\u202f: understanding data with graphs<\/em>, Packt Publishing<\/li>\r\n<\/ol>","rendered":"<div><span style=\"float: right;\"><a href=\"https:\/\/youtu.be\/O_4-4I27Ovc\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Overview of GNUPLOT<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">In this module, we will learn a plotting software that is used to create 2D and 3D plots. As you are aware that there are wide range of GUI software and spreadsheet packages that help us to create graphs and plots using a graphical interface. However, if we want to use mathematical expressions to plot charts, such kind of software will be of less help to us. Plotting features are available with various software like R, Python, etc. but they require programming knowledge of these languages. In this module, we will learn an open source tool GNUPLOT that does not require programming knowledge, by writing small scripts, we can generate efficient plots that can be of 2D or 3D.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Gnuplot is an open source command-line program, it is widely used by Engineers, Scientists, Data Analysts and Educators. It is used to generate 2D and 3D plots, these plots can be generated with the help of data or by using functions and mathematical expressions. It is distributed under GNU GPL and intially released in 1986. GNUPLOT runs on major OS like Linux, Unix, Windows, MacOS etc. Gnuplot can produce output directly on screen, or in many formats of graphics files, including Portable Network Graphics (PNG), Encapsulated PostScript (EPS), Scalable Vector Graphics (SVG), JPEG and many others. It is also capable of producing LaTeX code that can be included directly in LaTeX documents. Gnuplot can be used both interactively and in batch mode using scripts<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Installation<\/strong><\/p>\n<p style=\"text-align: justify;\">Gnuplot can be downloaded from the website :<a href=\"https:\/\/sourceforge.net\/projects\/gnuplot\/\">https:\/\/sourceforge.net\/projects\/gnuplot\/.<\/a>The software is available in binary form for Windows and is also available as open source or as repository for various linux distributions. We can install gnuplot for Redhat base distributions or for Ubuntu based distributions using the following command:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-437 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1.png\" alt=\"\" width=\"642\" height=\"63\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1.png 642w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1-300x29.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1-65x6.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1-225x22.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-1-350x34.png 350w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/p>\n<p><strong>Interface of Gnuplot<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Gnuplot has its own command line interface. We can see the interface by issuing gnuplot command on $ prompt in linux. The following screen illustrates the interface of Gnuplot:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-439 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K1.jpg\" alt=\"\" width=\"1440\" height=\"759\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1.jpg 1440w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-300x158.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-768x405.jpg 768w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-1024x540.jpg 1024w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-65x34.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-225x119.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K1-350x184.jpg 350w\" sizes=\"auto, (max-width: 1440px) 100vw, 1440px\" \/><\/p>\n<p style=\"text-align: center;\">Figure 1: Interface of GNUPLOT<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Gnuplot comes with its own default settings. For instance, when we plot data, it will be displayed with points and the functions are plotted with lines. There are default colors used for different functions. These default settings can be seen by issuing the following command:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-440 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2.png\" alt=\"\" width=\"631\" height=\"34\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2.png 631w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2-300x16.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2-65x4.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2-225x12.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/16-2-350x19.png 350w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><\/p>\n<p style=\"text-align: justify;\">There is always a default working directory associated so that the scripts can be read from the default directory. This default directory can be displayed using the following pwd command. The following screen shows output of \u201cpwd\u201d and \u201cshow style\u201d commands:<\/p>\n<p>.<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-441 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K2.jpg\" alt=\"\" width=\"1440\" height=\"672\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2.jpg 1440w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-300x140.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-768x358.jpg 768w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-1024x478.jpg 1024w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-65x30.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-225x105.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K2-350x163.jpg 350w\" sizes=\"auto, (max-width: 1440px) 100vw, 1440px\" \/><\/p>\n<p style=\"text-align: center;\">Figure 2: Output of pwd and show style commands<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Plotting functions<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">We can plot mathematical expressions and functions using gnuplot. For single function, we can simply call the function from command prompt. However, if we want to configure the output in desired format, there is a facility of writing scripts to configure the details of the output. Let us explore the commands and its related output using the gnuplot software.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-442 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K3.png\" alt=\"\" width=\"659\" height=\"291\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K3.png 659w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K3-300x132.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K3-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K3-225x99.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K3-350x155.png 350w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-443 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K4.png\" alt=\"\" width=\"575\" height=\"512\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K4.png 575w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K4-300x267.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K4-65x58.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K4-225x200.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K4-350x312.png 350w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-444 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K5.png\" alt=\"\" width=\"580\" height=\"254\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K5.png 580w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K5-300x131.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K5-65x28.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K5-225x99.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K5-350x153.png 350w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-445 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K6.png\" alt=\"\" width=\"543\" height=\"483\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K6.png 543w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K6-300x267.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K6-65x58.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K6-225x200.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K6-350x311.png 350w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-446 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K7.png\" alt=\"\" width=\"575\" height=\"270\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K7.png 575w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K7-300x141.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K7-65x31.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K7-225x106.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K7-350x164.png 350w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Writing Scripts<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">When we want to plot a more customization plot where different functions can be shown with different colors and styles, we write small scripts to manage desirable plots. In the following script, we have configured the border style, line style and titles. We have used two plots, each represented by f(x) and g(x) functions.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-447 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K8.png\" alt=\"\" width=\"537\" height=\"235\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K8.png 537w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K8-300x131.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K8-65x28.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K8-225x98.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K8-350x153.png 350w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">The output of above mentioned script is shown in figure 10. It must be noted that in the output, we have given title to f(x) plot and the linestyle is distinct from that of g(x) plot.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-448 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K9.png\" alt=\"\" width=\"418\" height=\"328\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K9.png 418w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K9-300x235.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K9-65x51.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K9-225x177.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K9-350x275.png 350w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Plotting data from file<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">We can plot data residing in file using gnuplot software. Let us seen an example of ploting some sample data where the data is used from a file. In the following example, our data is stored in a file \u201cdata1.dat\u201d. By issuing the following command, the data will be displayed in the desired line format. The output of the command is shown in figure 12 and the data is shown in figure 11.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-449 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K10.png\" alt=\"\" width=\"579\" height=\"295\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K10.png 579w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K10-300x153.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K10-65x33.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K10-225x115.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K10-350x178.png 350w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<p style=\"text-align: justify;\">While plotting data from a file, the data must be in columnar format as shown in above figure. We must also take care that the comments are used with a # sign.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Plotting Histogram<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Let us see an example where we plot a histogram using the gnuplot software. Although various types of charts can be plot, we will see a sample example of plotting histogram from some data file.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-450 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K11.png\" alt=\"\" width=\"584\" height=\"187\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11.png 584w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-300x96.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-65x21.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-225x72.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-350x112.png 350w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/p>\n<p style=\"text-align: justify;\">Using the above script, we have plot a histogram as shown in figure 14. The histogram is plotted using data from \u201cdata.dat\u201d file. The content of data file is shown in figure 13. As you can observe in the script, we have made labeling of x-axis in customized format. In the above script, we have used labels of x-axis as one of the columns that is the date. When we plot the histogram, the data is chosen from columns 2 to columns 4 and the labels are taken from column 1. These details are mentioned using the plot command. As shown in the script, the plot command takes filename, and labels of x-axis to generate the histogram.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-451 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1.png\" alt=\"\" width=\"584\" height=\"187\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1.png 584w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1-300x96.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1-65x21.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1-225x72.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/K11-1-350x112.png 350w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/p>\n<p style=\"text-align: justify;\">A variety of 2D and 3D plots can be generated using the gnuplot tool. There is a dedicated website that demonstrates different plots, the website <a href=\"http:\/\/www.gnuplot.info\/\">www.gnuplot.info <\/a>lists many scripts and their corresponding plots. Gnuplot can be integrated with other software like Latex, Octave, etc. to generate plots with the software environment.<\/p>\n<p>Let us summarize the key concepts covered in this module<\/p>\n<ul>\n<li>Overview of Gnuplot<\/li>\n<li>Plotting functions<\/li>\n<li>Modifying styles while plotting<\/li>\n<li>Plotting from data file<\/li>\n<li>Plotting a histogram using script<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on GNUPLOT<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/O_4-4I27Ovc\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>References for GNUPLOT:<\/strong><\/p>\n<ol>\n<li style=\"text-align: justify;\">GNUPlot Home Page. http:\/\/gnuplot.info\/<\/li>\n<li style=\"text-align: justify;\">Lee. Philipps. 2012. <em>Gnuplot cookbook\u202f: over 80 recipes to visually explore the full<\/em> <em>range of features of the world\u2019s preeminent open source graphing system<\/em>, Packt Publishing.<\/li>\n<li style=\"text-align: justify;\">Jeroen Janssens. <em>Data science at the command line<\/em>,<\/li>\n<li style=\"text-align: justify;\">Thomas Williams and Colin Kelley. 2015. <em>Gnuplot 5.0 Reference manual<\/em>, Samurai Media Limited.<\/li>\n<li style=\"text-align: justify;\">Philipp K. Janert. <em>Gnuplot in action\u202f: understanding data with graphs<\/em>, Packt Publishing<\/li>\n<\/ol>\n","protected":false},"author":4,"menu_order":31,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["mr-hardik-joshi"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-436","chapter","type-chapter","status-publish","hentry","contributor-mr-hardik-joshi"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/users\/4"}],"version-history":[{"count":7,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/436\/revisions"}],"predecessor-version":[{"id":721,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/436\/revisions\/721"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/436\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/media?parent=436"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapter-type?post=436"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/contributor?post=436"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/license?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}