.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Chart::Gnuplot 3pm" .TH Chart::Gnuplot 3pm "2011-09-17" "perl v5.12.4" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Chart::Gnuplot \- Plot graph using Gnuplot in Perl on the fly .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Chart::Gnuplot; \& \& # Data \& my @x = (\-10 .. 10); \& my @y = (0 .. 20); \& \& # Create chart object and specify the properties of the chart \& my $chart = Chart::Gnuplot\->new( \& output => "fig/simple.png", \& title => "Simple testing", \& xlabel => "My x\-axis label", \& ylabel => "My y\-axis label", \& .... \& ); \& \& # Create dataset object and specify the properties of the dataset \& my $dataSet = Chart::Gnuplot::DataSet\->new( \& xdata => \e@x, \& ydata => \e@y, \& title => "Plotting a line from Perl arrays", \& style => "linespoints", \& .... \& ); \& \& # Plot the data set on the chart \& $chart\->plot2d($dataSet); \& \& ################################################## \& \& # Plot many data sets on a single chart \& $chart\->plot2d($dataSet1, $dataSet2, ...); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This Perl module is to plot graphs uning \s-1GNUPLOT\s0 on the fly. In order to use this module, gnuplot need to be installed. If image format other than \s-1PS\s0 and \&\s-1EPS\s0 is required to generate, the convert program of ImageMagick is also needed. .PP To plot chart using Chart::Gnuplot, a chart object and at least one dataset object are required. Information about the chart such as output file, chart title, axes labels and so on is specified in the chart object. Dataset object contains information about the dataset to be plotted, including source of the data points, dataset label, color used to plot and more. .PP After chart object and dataset object(s) are created, the chart can be plotted using the plot2d, plot3d or multiplot method of the chart object, e.g. .PP .Vb 2 \& # $chart is the chart object \& $chart\->plot2d($dataSet1, $dataSet2, ...); .Ve .PP To illustate the features of Chart::Gnuplot, the best way is to show by examples. A lot of examples can be found in SourceForge . .SH "CHART OBJECT" .IX Header "CHART OBJECT" The chart object can be initiated by the c method. Properties of the chart may be specified optionally when the object is initiated: .PP .Vb 1 \& my $chart = Chart::Gnuplot\->new(%options); .Ve .SS "Chart Options" .IX Subsection "Chart Options" \fIoutput\fR .IX Subsection "output" .PP Output file of the graph. By default, the image format is detected automatically by the extension of the filename. However, it can also be changed manually by using the format conversion methods such as \f(CW\*(C`convert\*(C'\fR and \f(CW\*(C`png\*(C'\fR (see sessions below). .PP The supported image formats are: .PP .Vb 12 \& bmp : Microsoft Windows bitmap \& epdf : Encapsulated Portable Document Format \& epi : Encapsulated PostScript Interchange format \& eps : Encapsulated PostScript \& gif : Graphics Interchange Format \& jpg : Joint Photographic Experts Group JFIF format \& pdf : Portable Document Format \& png : Portable Network Graphics \& ppm : Portable Pixmap Format \& ps : PostScript file \& psd : Adobe Photoshop bitmap file \& xpm : X Windows system pixmap .Ve .PP If the filename has no extension, postscipt will be used. .PP \fItitle\fR .IX Subsection "title" .PP Title of the chart. E.g., .PP .Vb 1 \& title => "Chart title" .Ve .PP Properties of the chart title can be specified in hash. E.g., .PP .Vb 5 \& title => { \& text => "Chart title", \& font => "arial, 20", \& .... \& } .Ve .PP Supported properties are: .PP .Vb 5 \& text : title in plain text \& font : font face (and optionally font size) \& color : font color \& offset : offset relative to the default position \& enhanced : title contains subscript/superscipt/greek? (on/off) .Ve .PP Default values would be used for properties not specified. These properties has no effect on the main title of the multi-chart (see multiplot). .PP \fIxlabel, ylabel, zlabel\fR .IX Subsection "xlabel, ylabel, zlabel" .PP Label of the x\-axis, y\-axis and z\-axis. E.g. .PP .Vb 1 \& xlabel => "Bottom axis label" .Ve .PP Properties of the axis label can be specified in hash, similar to the chart title. Supported properties are: .PP .Vb 6 \& text : title in plain text \& font : font face (and optionally font size) \& color : font color \& offset : offset relative to the default position \& rotate : rotation in degrees \& enhanced : title contains subscript/superscipt/greek? (on/off) .Ve .PP \fIx2label, y2label\fR .IX Subsection "x2label, y2label" .PP Label of the secondary x\-axis (displayed on the top of the graph) and the secondary y\-axis (displayed on the right of the graph). See xlabel. .PP \fIxrange, yrange, zrange\fR .IX Subsection "xrange, yrange, zrange" .PP Range of the x\-axis, y\-axis and z\-axis in the plot, e.g. .PP .Vb 1 \& xrange => [0, "pi"] .Ve .PP would make the plot from x = 0 to x = 3.14159... .PP \fIx2range, y2range\fR .IX Subsection "x2range, y2range" .PP Range of the secondary (top horizontal and right vertical) axes of the plot. See \*(L"xrange, yrange, zrange\*(R". .PP \fItrange, urange, vrange\fR .IX Subsection "trange, urange, vrange" .PP Range of the parametric parameter (t for 2D plots, while u and v for 3D plots). See \*(L"xrange, yrange, zrange\*(R". .PP \fIxtics, ytics, ztics\fR .IX Subsection "xtics, ytics, ztics" .PP The tics and tic label on the x\-axis, y\-axis and z\-axis. E.g. .PP .Vb 5 \& xtics => { \& labels => [\-10, 15, 20, 25], \& labelfmt => "%3f", \& .... \& } .Ve .PP If you set this to \f(CW\*(C`undef\*(C'\fR. E.g., .PP .Vb 1 \& xtics => undef .Ve .PP Then this option will be explicitly \fIunset\fR and the chart will have not have tic marks on the specified axis. .PP Supported properties are: .PP .Vb 12 \& labels : the locations of the tic labels \& labelfmt : format of the labels \& font : font of the labels \& fontsize : font size of the lebals \& fontcolor : font color of the label \& offset : position of the tic labels shifted from its default \& rotate : rotation of the tic labels \& length : length of the tics \& along : where the tics are put (axis/border) \& minor : number of minor tics between adjacant major tics \& mirror : turn on and off the tic label of the secondary axis. No effect \& : for C (on/off) .Ve .PP \fIx2tics, y2tics\fR .IX Subsection "x2tics, y2tics" .PP The tics and tic label of the secondary axes. See \*(L"xtics, ytics, ztics\*(R". .PP \fIlegend\fR .IX Subsection "legend" .PP Legend describing the plots. Supported properties are: .PP .Vb 10 \& position : position of the legend \& width : number of character widths to be added or subtracted to the \& : region of the legend \& height : number of character heights to be added or subtracted to the \& : region of the legend \& align : alignment of the text label. Left or right (default) \& order : order of the keys \& title : title of the legend \& sample : format of the sample lines \& border : border of the legend .Ve .PP See border for the available options of border .PP E.g. .PP .Vb 10 \& legend => { \& position => "outside bottom", \& width => 3, \& height => 4, \& align => "right", \& order => "horizontal reverse", \& title => "Title of the legend", \& sample => { \& length => 3, \& position => "left", \& spacing => 2, \& }, \& border => { \& linetype => 2, \& width => 1, \& color => "blue", \& }, \& } .Ve .PP \fItimeaxis\fR .IX Subsection "timeaxis" .PP Specify the axes of which the tic labels are date/time string. Possible values are combinations of \*(L"x\*(R", \*(L"y\*(R", \*(L"x2\*(R", and \*(L"y2\*(R" joined by \*(L",\*(R". E.g. .PP .Vb 1 \& timeaxis => "x, y2" .Ve .PP means that the x\-axis and y2\-axis are data/time axes. .PP \fIborder\fR .IX Subsection "border" .PP Border of the graph. Properties supported are \*(L"sides\*(R", \*(L"linetype\*(R", \*(L"width\*(R", and \&\*(L"color\*(R". E.g. .PP .Vb 6 \& border => { \& sides => "bottom, left", \& linetype => 3, \& width => 2, \& color => \*(Aq#ff00ff\*(Aq, \& } .Ve .PP \&\f(CW\*(C`sides\*(C'\fR tells which side(s) will be displayed. Default is all four borders for 2D plots, and four bottom and left vertial borders for 3D plots. Acceptable valurs are the 12\-bit code (see the Gnuplot manual) or the following names: .PP .Vb 10 \& bottom \& left \& top \& right \& bottom left front \& bottom left back \& bottom right front \& bottom right back \& left vertical \& right vertical \& front vertical \& back vertical \& top left front \& top left back \& top right front \& top right back .Ve .PP If you set this to \f(CW\*(C`undef\*(C'\fR. E.g., .PP .Vb 1 \& border => undef .Ve .PP Then this option will be explicitly \fIunset\fR and the chart will have not have any border. .PP \fIgrid\fR .IX Subsection "grid" .PP Major grid lines. E.g. .PP .Vb 5 \& grid => { \& type => \*(Aqdash\*(Aq, \& width => 2, \& .... \& } .Ve .PP Supported properties are: .PP .Vb 5 \& type : line type of the grid lines (default: dot) \& width : line width (defaulr: 0) \& color : line color (default: black) \& xlines : whether the vertical grid lines are drawn (on/off) \& ylines : whether the horizontal grid lines are drawn (on/off) .Ve .PP \fItmargin, bmargin\fR .IX Subsection "tmargin, bmargin" .PP Top and bottom margin (in character height). This option has no effect in 3D plots. E.g. .PP .Vb 1 \& tmargin => 10 .Ve .PP \fIlmargin, rmargin\fR .IX Subsection "lmargin, rmargin" .PP Left amd right margin (in character width). This option has no effect in 3D plots. See \*(L"tmargin, bmargin\*(R". .PP \fIorient\fR .IX Subsection "orient" .PP Orientation of the image. Possible values are \*(L"lanscape\*(R" (default) and \&\*(L"portrait\*(R". E.g. .PP .Vb 1 \& orient => "portrait" .Ve .PP \fIimagesize\fR .IX Subsection "imagesize" .PP Size (length and height) of the image relative to the default. E.g. .PP .Vb 1 \& imagesize => "0.8, 0.5" .Ve .PP \fIsize\fR .IX Subsection "size" .PP Size of the plot relative to the chart size. This is useful in some multi-plot such as inset chart. E.g. .PP .Vb 1 \& size => "0.5, 0.4" .Ve .PP \fIorigin\fR .IX Subsection "origin" .PP Origin of the chart. This is useful in some multi-plot such as inset chart. E.g. .PP .Vb 1 \& origin => "0.1, 0.5" .Ve .PP \fItimestamp\fR .IX Subsection "timestamp" .PP Time stamp of the plot. To place the time stamp with default setting, .PP .Vb 1 \& timestamp => \*(Aqon\*(Aq .Ve .PP To set the format of the time stamp as well, e.g., .PP .Vb 5 \& timestamp => { \& fmt => \*(Aq%d/%m/%y %H:%M\*(Aq, \& offset => "10,\-3", \& font => "Helvetica", \& } .Ve .PP \fIbg (experimental)\fR .IX Subsection "bg (experimental)" .PP Background color of the chart. This option has no effect in the sub-chart of multiplot and is experimental. E.g. .PP .Vb 1 \& bg => "yellow" .Ve .PP Properties can be specified in hash. E.g., .PP .Vb 4 \& bg => { \& color => "yellow", \& density => 0.2, \& } .Ve .PP Supported properties are: .PP .Vb 2 \& color : color (name ot RRGGBB value) \& density : density of the coloring .Ve .PP \fIplotbg (experimental)\fR .IX Subsection "plotbg (experimental)" .PP Background color of the plot area. This option has no effect in 3D plots and is experimental. See bg. .PP \fIgnuplot\fR .IX Subsection "gnuplot" .PP The path of Gnuplot executable. This option is useful if you are using Windows or have multiple versions of Gnuplot installed. E.g., .PP .Vb 1 \& gnuplot => "C:\eProgram Files\e...\egnuplot\ebin\ewgnuplot.exe"; # for Windows .Ve .PP \fIconvert\fR .IX Subsection "convert" .PP The path of convert executable of ImageMagick. This option is useful if you have multiple convert executables. .PP \fIterminal\fR .IX Subsection "terminal" .PP The terminal driver that Gnuplot uses. The default terminal is \*(L"postscript\*(R". This attribute is not recommended to be changed unless you are familiar with the Gnuplot syntax. Please check the output image carefully if you use this in production code. .PP Terminal is not necessarily related to the output image format. You may convert the image format by the \f(CW\*(C`convert()\*(C'\fR method. .SS "Chart Methods" .IX Subsection "Chart Methods" \fInew\fR .IX Subsection "new" .PP .Vb 1 \& my $chart = Chart::Gnuplot\->new(%options); .Ve .PP Constructor of the chart object. If no option is specified, default values would be used. See \*(L"Chart Options\*(R" for available options. .PP \fIset\fR .IX Subsection "set" .PP General set methods for arbitrary number of options. .PP .Vb 1 \& $chart\->set(%options); .Ve .PP \fIplot2d\fR .IX Subsection "plot2d" .PP .Vb 1 \& $chart\->plot2d(@dataSets); .Ve .PP Plot the data sets in a 2D chart. Each dataset is represented by a dataset object. .PP \fIplot3d\fR .IX Subsection "plot3d" .PP .Vb 1 \& $chert\->plot3d(@dataSets); .Ve .PP Plot the data sets in a 3D chart. Each dataset is represented by a dataset object. It is not yet completed. Only basic features are supported. .PP \fImultiplot\fR .IX Subsection "multiplot" .PP .Vb 1 \& $chert\->multiplot(@charts); .Ve .PP Plot multiple charts in the same image. .PP \fIanimate\fR .IX Subsection "animate" .PP Create animated gif. E.g. .PP .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& output => "animate.gif", \& ); \& \& my $T = 30; # number of frames \& my @c; \& for (my $i = 0; $i < $T; $i++) \& { \& $c[$i] = Chart::Gnuplot\->new(xlabel => \*(Aqx\*(Aq); \& my $ds = Chart::Gnuplot::DataSet\->new( \& func => "sin($i*2*pi/$T + x)", \& ); \& $c[$i]\->add2d($ds); \& } \& \& $chart\->animate( \& charts => \e@c, \& delay => 10, # delay 0.1 sec between successive images \& ); .Ve .PP Supported properties are: .PP .Vb 3 \& charts : chart sequence used to create the animation \& delay : delay (in units of 0.01 second) between successive images, default \& : value is 5 .Ve .PP See add2d and add3d. .PP \fIadd2d\fR .IX Subsection "add2d" .PP Add a 2D dataset to a chart without plotting it out immediately. Used with \&\f(CW\*(C`multiplot\*(C'\fR or \f(CW\*(C`animate\*(C'\fR. .PP \fIadd3d\fR .IX Subsection "add3d" .PP Add a 3D dataset to a chart without plotting it out immediately. Used with \&\f(CW\*(C`multiplot\*(C'\fR or \f(CW\*(C`animate\*(C'\fR. .PP \fIlabel\fR .IX Subsection "label" .PP Add an arbitrary text label. e.g., .PP .Vb 11 \& $chart\->label( \& text => "This is a label", \& position => "0.2, 3 left", \& offset => "2,2", \& rotate => 45, \& font => "arial, 15", \& fontcolor => "dark\-blue", \& pointtype => 3, \& pointsize => 5, \& pointcolor => "blue", \& ); .Ve .PP \fIarrow\fR .IX Subsection "arrow" .PP Draw arbitrary arrow. e.g., .PP .Vb 9 \& $chart\->arrow( \& from => "0,2", \& to => "0.3,0.1", \& linetype => \*(Aqdash\*(Aq, \& width => 2, \& color => "dark\-blue", \& headsize => 3, \& head => \*(Aqboth\*(Aq, \& ); .Ve .PP \fIcopy\fR .IX Subsection "copy" .PP Copy the chart object. This method is especially useful when you want to copy a chart with highly customized format. E.g. .PP .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& ... \& ); \& \& # $copy and $chart will have the same format \& my $copy = $chart\->copy; .Ve .PP You may also make multiple copies . E.g. .PP .Vb 1 \& my @copies = $chart\->copy(10); # make 10 copies .Ve .PP \fIconvert\fR .IX Subsection "convert" .PP .Vb 1 \& $chart\->convert($imageFmt); .Ve .PP Convert the image format to \f(CW$imageFmt\fR. See \*(L"Chart Options\*(R" for supported image formats. .PP \fIpng\fR .IX Subsection "png" .PP .Vb 1 \& $chart\->png; .Ve .PP Change the image format to \s-1PNG\s0. .PP \fIgif\fR .IX Subsection "gif" .PP .Vb 1 \& $chart\->gif; .Ve .PP Change the image format to \s-1GIF\s0. .PP \fIjpg\fR .IX Subsection "jpg" .PP .Vb 1 \& $chart\->jpg; .Ve .PP Change the image format to \s-1JPEG\s0. .PP \fIps\fR .IX Subsection "ps" .PP .Vb 1 \& $chart\->ps; .Ve .PP Change the image format to postscript. .PP \fIpdf\fR .IX Subsection "pdf" .PP .Vb 1 \& $chart\->pdf .Ve .PP Change the image format to \s-1PDF\s0. .PP \fIcommand\fR .IX Subsection "command" .PP .Vb 1 \& $chart\->command($gnuplotCommand); .Ve .PP Add a gnuplot command. This method is useful for the Gnuplot features that have not yet implemented. .SH "DATASET OBJECT" .IX Header "DATASET OBJECT" The dataset object can be initiated by the \f(CW\*(C`new\*(C'\fR method. Properties of the dataset may be specified optionally when the object is initiated: .PP .Vb 1 \& my $dataset = Chart::Gnuplot::DataSet\->new(%options); .Ve .PP The data source of the dataset can be specified by either one of the following ways: .IP "1. Arrays of x values, y values and z values (in 3D plots) of the data points." 4 .IX Item "1. Arrays of x values, y values and z values (in 3D plots) of the data points." .PD 0 .IP "2. Array of data points. Each point is specified as an array of x, y, z coordinates" 4 .IX Item "2. Array of data points. Each point is specified as an array of x, y, z coordinates" .IP "3. Data file." 4 .IX Item "3. Data file." .IP "4. Mathematical expression (for a function)." 4 .IX Item "4. Mathematical expression (for a function)." .PD .SS "Dataset Options" .IX Subsection "Dataset Options" \fIxdata, ydata, zdata\fR .IX Subsection "xdata, ydata, zdata" .PP The x, y, z values of the data points. E.g. .PP .Vb 1 \& xdata => \e@x .Ve .PP If \f(CW\*(C`xdata\*(C'\fR is omitted but \f(CW\*(C`ydata\*(C'\fR is defined, the integer index starting from 0 would be used for \f(CW\*(C`xdata\*(C'\fR. .PP \fIpoints\fR .IX Subsection "points" .PP Data point matrix of the format [[x1,y1], [x2,y2], [x3,y3], ...] .PP .Vb 1 \& points => \e@points .Ve .PP \fIdatafile\fR .IX Subsection "datafile" .PP Input data file .PP .Vb 1 \& datafile => $file .Ve .PP The data files are assumed to be space-separated, with each row corresponding to one data point. Lines beginning with \*(L"#\*(R" are considered as comments and would be ignored. Other formats are not supported at this moment. .PP \fIfunc\fR .IX Subsection "func" .PP Mathematical function to be plotted. E.g. .PP .Vb 1 \& func => "sin(x)*x**3" .Ve .PP Supported functions: .PP .Vb 10 \& abs(x) : absolute value \& acos(x) : inverse cosine \& acosh(x) : inverse hyperbolic cosine \& arg(x) : complex argument \& asin(x) : inverse sine \& asinh(x) : inverse hyperbolic sine \& atan(x) : inverse tangent \& atanh(x) : inverse hyperbolic tangent \& besj0(x) : zeroth order Bessel function of the first kind \& besj1(x) : first order Bessel function of the first kind \& besy0(x) : zeroth order Bessel function of the second kind \& besy1(x) : first order Bessel function of the second kind \& ceil(x) : ceiling function \& cos(x) : cosine \& cosh(x) : hyperbolic cosine \& erf(x) : error function \& erfc(x) : complementary error function \& exp(x) : expontial function \& floor(x) : floor function \& gamma(x) : gamma function \& ibeta(a,b,x) : incomplete beta function \& inverf(x) : inverse error function \& igamma(a,x) : incomplete gamma function \& imag(x) : imaginary part \& invnorm(x) : inverse normal distribution function \& int(x) : integer part \& lambertw(x) : Lambert W function \& lgamma(x) : log gamma function \& log(x) : natural logarithm \& log10(x) : common logarithm \& norm(x) : normal distribution function \& rand(x) : pseudo random number \& real(x) : real part \& sgn(x) : sign function \& sin(x) : sine \& sinh(x) : hyperbolic sine \& sqrt(x) : square root \& tan(x) : tangent \& tanh(x) : hyperbolic tangent .Ve .PP Please see the Gnuplot manual for updated information. .PP Supported mathematical constants: .PP .Vb 1 \& pi : the circular constant 3.14159... .Ve .PP Supported arithmetic operators: .PP .Vb 8 \& addition : + \& division : / \& exponentiation : ** \& factorial : ! \& modulo : % \& multiplication : * \& subtraction : \-, e.g., 1\-2 \& unary minus : \-, e.g., \-1 .Ve .PP Supported logical operations: .PP .Vb 11 \& and : && \& complement : ~ \& equality : == \& greater than : > \& greater than or equal to : >= \& inequality : != \& less than : < \& less than or equal to : <= \& negation : ! \& or : || \& if ... than else ... : ?:, e.g., a ? b : c .Ve .PP Parametric functions may be represented as hash. E.g. .PP .Vb 1 \& func => {x => \*(Aqsin(t)\*(Aq, y => \*(Aqcos(t)\*(Aq} .Ve .PP will draw a circle. .PP \fItitle\fR .IX Subsection "title" .PP Title of the dataset (shown in the legend). .PP \fIstyle\fR .IX Subsection "style" .PP The plotting style for the dataset, including .PP .Vb 10 \& lines : join adjacent points by straight lines \& points : mark each points by a symbol \& linespoints : both "lines" and "points" \& dots : dot each points. Useful for large datasets \& impluses : draw a vertical line from the x\-axis to each point \& steps : join adjacent points by steps \& boxes : draw a centered box from the x\-axis to each point \& xerrorbars : "dots" with horizontal error bars \& yerrorbars : "dots" with vertical error bars \& xyerrorbars : both "xerrorbars" and "yerrorbars" \& xerrorlines : "linespoints" with horizontal error bars \& yerrorlines : "linespoints" with vertical error bars \& xyerrorlines : both "xerrorlines" and "yerrorlines" \& boxerrorbars : "boxes" with "yerrorbars" \& boxxyerrorbars : use rectangles to represent the data with errors \& financebars : finance bars for open, high, low and close price \& candlesticks : candle sticks for open, high, low and close price \& hbars : horizontal bars (experimental) \& hlines : horizontal lines (experimental) .Ve .PP \fIcolor\fR .IX Subsection "color" .PP Color of the dataset in the plot. Can be a named color ot \s-1RBG\s0 (#RRGGBB) value. The supported color names can be found in the file \fIdoc/colors.txt\fR in the distribution. E.g. .PP .Vb 3 \& color => "#99ccff" \& # or \& color => "dark\-red" .Ve .PP \fIwidth\fR .IX Subsection "width" .PP Line width used in the plot. .PP \fIlinetype\fR .IX Subsection "linetype" .PP Line type. .PP \fIpointtype\fR .IX Subsection "pointtype" .PP Point type. .PP \fIpointsize\fR .IX Subsection "pointsize" .PP Point size of the plot. .PP \fIfill\fR .IX Subsection "fill" .PP Filling string. Has effect only on plotting styles \*(L"boxes\*(R", \*(L"boxxyerrorbars\*(R" and \*(L"financebars\*(R". .PP \fIaxes\fR .IX Subsection "axes" .PP Axes used in the plot. Possible values are \*(L"x1y1\*(R", \*(L"x1y2\*(R", \*(L"x2y1\*(R" and \*(L"x2y2\*(R". .PP \fItimefmt\fR .IX Subsection "timefmt" .PP Time format of the input data. The valid format are: .PP .Vb 11 \& %d : day of the month, 1\-31 \& %m : month of the year, 1\-12 \& %y : year, 2\-digit, 0\-99 \& %Y : year, 4\-digit \& %j : day of the year, 1\-365 \& %H : hour, 0\-24 \& %M : minute, 0\-60 \& %s : seconds since the Unix epoch (1970\-01\-01 00:00 UTC) \& %S : second, 0\-60 \& %b : name of the month, 3\-character abbreviation \& %B : name of the month .Ve .PP \fIsmooth\fR .IX Subsection "smooth" .PP The smooth method used in plotting data points. Supported methods include cubic splines (csplines), Bezier curve (bezier) and other. Please see Gnuplot manual for details. .SS "Dataset Methods" .IX Subsection "Dataset Methods" \fInew\fR .IX Subsection "new" .PP .Vb 1 \& my $dataset = Chart::Gnuplot::DataSet\->new(%options); .Ve .PP Constructor of the dataset object. If no option is specified, default values would be used. See \*(L"Dataset Options\*(R" for available options. .PP \fIcopy\fR .IX Subsection "copy" .PP Copy the dataset object. This method is especially useful when you want to copy a dataset with highly customized format. E.g. .PP .Vb 3 \& my $dataset = Chart::Gnuplot::DataSet\->new( \& ... \& ); \& \& # $copy and $dataset will have the same format and contain the same data \& my $copy = $dataset\->copy; .Ve .PP You may also make multiple copies . E.g. .PP .Vb 1 \& my @copies = $dataset\->copy(10); # make 10 copies .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" Some simple examples are shown below. Many more come with the distribution. .IP "1. Plot a mathematical expression" 4 .IX Item "1. Plot a mathematical expression" .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& output => "expression.png" \& ); \& \& my $dataSet = Chart::Gnuplot::DataSet\->new( \& func => "sin(x)" \& ); \& \& $chart\->plot2d($dataSet); .Ve .IP "2. Plot from two Perl arrays, one for the x\-axis data and the other the y\-axis." 4 .IX Item "2. Plot from two Perl arrays, one for the x-axis data and the other the y-axis." .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& output => "arrays.png" \& ); \& \& my $dataSet = Chart::Gnuplot::DataSet\->new( \& xdata => \e@x, \& ydata => \e@y, \& ); \& \& $chart\->plot2d($dataSet); .Ve .IP "3. Plot x\-y pairs" 4 .IX Item "3. Plot x-y pairs" .Vb 7 \& # Data \& my @xy = ( \& [1.1, \-3], \& [1.2, \-2], \& [3.5, 0], \& ... \& ); \& \& my $chart = Chart::Gnuplot\->new( \& output => "points.png" \& ); \& \& my $dataSet = Chart::Gnuplot::DataSet\->new( \& points => \e@xy \& ); \& \& $chart\->plot2d($dataSet); .Ve .IP "4. Plot data from a data file" 4 .IX Item "4. Plot data from a data file" .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& output => "file.png" \& ); \& \& my $dataSet = Chart::Gnuplot::DataSet\->new( \& datafile => "in.dat" \& ); \& \& $chart\->plot2d($dataSet); .Ve .IP "5. Chart title, axis label and legend" 4 .IX Item "5. Chart title, axis label and legend" .Vb 7 \& # Chart object \& my $chart = Chart::Gnuplot\->new( \& output => "trigonometric.gif", \& title => "Three basic trigonometric functions", \& xlabel => "angle in radian", \& ylabel => "function value" \& ); \& \& # Data set objects \& my $sine = Chart::Gnuplot::DataSet\->new( \& func => "sin(x)", \& title => "sine function" \& ); \& my $cosine = Chart::Gnuplot::DataSet\->new( \& func => "cos(x)", \& title => "cosine function" \& ); \& my $tangent = Chart::Gnuplot::DataSet\->new( \& func => "tan(x)", \& title => "tangent function" \& ); \& \& $chart\->plot2d($sine, $cosine, $tangent); .Ve .IP "6. Title in non-English characters (Thanks to WOLfgang Schricker)" 4 .IX Item "6. Title in non-English characters (Thanks to WOLfgang Schricker)" .Vb 1 \& use Encode; \& \& my $title = ... # Title with German umlauts \& $title = decode("utf8", $title); \& \& Chart::Gnuplot\->new( \& encoding => \*(Aqiso\-8859\-1\*(Aq, \& title => $title, \& ); .Ve .IP "7. Plot a financial time series" 4 .IX Item "7. Plot a financial time series" .Vb 8 \& my $chart = Chart::Gnuplot\->new( \& output => "dj.ps", \& title => "Dow\-Jones Index time series", \& timeaxis => \*(Aqx\*(Aq, \& xtics => { \& labelfmt => \*(Aq%b%y\*(Aq, \& }, \& ); \& \& my $dow = Chart::Gnuplot::DataSet\->new( \& file => "dj.dat", \& timefmt => \*(Aq%Y\-%m\-%d\*(Aq, # time format of the input data \& style => "candlesticks", \& grid => \*(Aqon\*(Aq, \& ); \& \& $chart\->plot2d($dow); .Ve .IP "8. Plot several graphs on the same image" 4 .IX Item "8. Plot several graphs on the same image" .Vb 3 \& my $chart = Chart::Gnuplot\->new( \& output => "multiplot.gif", \& ); \& \& my $left = Chart::Gnuplot\->new(); \& my $sine = Chart::Gnuplot::DataSet\->new( \& func => "sin(x)", \& ); \& $left\->add2d($sine); \& \& my $center = Chart::Gnuplot\->new(); \& my $cosine = Chart::Gnuplot::DataSet\->new( \& func => "cos(x)", \& ); \& $center\->add2d($cosine); \& \& my $right = Chart::Gnuplot\->new(); \& my $tangent = Chart::Gnuplot::DataSet\->new( \& func => "tan(x)", \& ); \& $right\->add2d($tangent); \& \& # Place the Chart::Gnuplot objects in matrix to indicate their locations \& $chart\->multiplot([ \& [$left, $center, $right] \& ]); .Ve .SH "WISH LIST" .IX Header "WISH LIST" .IP "1. Improve the manual." 4 .IX Item "1. Improve the manual." .PD 0 .IP "2. Add more control to the 3D plots." 4 .IX Item "2. Add more control to the 3D plots." .IP "3. Add curve fitting method." 4 .IX Item "3. Add curve fitting method." .IP "4. Improve the testsuite." 4 .IX Item "4. Improve the testsuite." .IP "5. Reduce number of temporary files generated." 4 .IX Item "5. Reduce number of temporary files generated." .PD .SH "REQUIREMENTS" .IX Header "REQUIREMENTS" Carp, File::Copy, File::Temp, Storable .PP Gnuplot .PP ImageMagick (for full feature) .SH "SEE ALSO" .IX Header "SEE ALSO" Gnuplot official website .SH "AUTHOR" .IX Header "AUTHOR" Ka-Wai Mak .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2008\-2011 Ka-Wai Mak. All rights reserved. .SH "LICENSE" .IX Header "LICENSE" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.