gadbermd has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, I've just started using Chart::Gnuplot and I'm having a problem where it's stacking all my time series data points at midnight versus spreading that data out across the day. It's seems like it doesn't recognize the H:M:S portion of the date I'm feeding it? I'm reading date/price values out of a MySQL table (from TIMESTAMP and INTEGER columns) and then plotting them out. The code looks like this...
$query = "SELECT distinct date, priceInCents FROM META_VAL WHERE date +>= DATE_SUB(NOW(), INTERVAL 7 DAY) ORDER BY date ASC"; $sth = $dbh->prepare($query); $sth->execute or die "SQL Error: $DBI::errstr\n"; while (my @result = $sth->fetchrow_array) { push @dates, $result[0]; push @prices, ($result[1]/100); } my $mygraph = Chart::Gnuplot->new( output => "chart.png", timeaxis => 'x', xlabel => 'Date', ylabel => 'Price', } my $data = Chart::Gnuplot::DataSet->new( xdata => \@dates, ydata => \@prices, style => 'linespoints', timefmt => '%Y-%m-%d $H:%M:%S', # input time format ); $mygraph->plot2d($data);
...and some sample data looks like this...
2015-03-02 10:09:00 4615 2015-03-02 20:22:00 4645 2015-03-03 10:30:00 4610 2015-03-03 20:36:00 4625 2015-03-04 10:43:00 4603 2015-03-04 20:49:00 4790 2015-03-05 10:54:00 4724 2015-03-05 20:54:00 4834
...but like I said, the graph that is created has "islands" of points at midnight with no data points in between (like a normal stock price chart). I feel like I'm missing something obvious but my Google searches and Perl Monks searches haven't yielded anything. Cheers and thanks!

Replies are listed 'Best First'.
Re: Chart::Gnuplot stacking data at midnight?
by choroba (Cardinal) on Apr 03, 2015 at 16:21 UTC
    Note that $H is not the same as %H.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Dang it! Well that was easy. Thanks choroba, I knew it was something obvious.