File: datetime_2.pl

package info (click to toggle)
libchart-gnuplot-perl 0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 944 kB
  • sloc: perl: 4,862; makefile: 113
file content (36 lines) | stat: -rwxr-xr-x 660 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w
use strict;
use Chart::Gnuplot;

# Time array
my @x = qw(
    00:00:00
    03:05:24
    06:15:58
    10:03:20
    10:57:00
    11:42:32
    13:30:03
    15:00:30
    17:23:27
    19:38:41
);
my @y = (1 .. 10);

# Create the chart object
my $chart = Chart::Gnuplot->new(
    output   => 'gallery/datetime_2.png',
    xlabel   => 'Time axis',
    timeaxis => "x",            # declare that x-axis uses time format
);

# Data set object
my $data = Chart::Gnuplot::DataSet->new(
    xdata   => \@x,
    ydata   => \@y,
    style   => 'linespoints',
    timefmt => '%H:%M:%S',      # input time format
);

# Plot the graph
$chart->plot2d($data);