Thu 14 May 2015 06:08:05 AM UTC, comment #5:
In further floundering, I thought to try converting the values for the "stairs" plot into a sequence of (x,y) points at the corners of the stairs, then use the ordinary plot(x,y) command. This was hoped to work because in the tests, the point-wise plotting of (x,y) came out as expected.
Alas, the joined-line plotted stairs also came out incorrectly, even though the pointwise plotted points were good.
Plan B is to try shifting the date axis. Subtracting 730485 removes two millenia from the date number, bringing modern dates to daynumbers much closer to the notional zero. Unfortunately, this makes a mess of the annotation of the date axis. And a lot of testing will be needed as negative years may behave differently, for instance the MOD function can differ on different computers.
|
Tue 28 Apr 2015 10:04:20 AM UTC, comment #4:
Aha. "graphics_toolkit gnuplot" takes effect after I close the window holding the plot, whereupon a new window is opened, and the stairs appear correctly.
But, the y-axis annotation ("MEGA Watts") no longer appears vertically, it appears horizontally, and thus extends past the margin area!
Details, details...
|
Tue 28 Apr 2015 09:34:18 AM UTC, comment #3:
After getting some sleep (and signing up), I have just tried again to see what's happening. The x-axis is a day number, of the order 723637 for the first of April 1982. Thus, the second day's data has x-axis values of 723638 - both with fractional parts for the fraction of the day. If I take the x-array and calculate xh = (x - x(1))*24 the x-values are of the order 0:48, and, the plot comes out correctly with the right number of steps (leaving aside the issue of the first step) and no mysterious ticks.
Thus, the suggestion that the problem is caused by single-precision arithmetic within the plotting system looks to explain the oddities. For what it's worth, I've always used 31/12/1899 (a Sunday) as day zero precisely so as not to strain the precision capacity, and used double precision anyway.
I tried graphics_toolkit gnuplot (as a command to Octave; it was accepted as such or at least, no remark was made) but there was no improvement to my test plot.
The way ahead looks to be a recasting of the scheme for the x-axis, perhaps indeed rebasing to 31/12/1899 or even 1/1/2000 or similar to be in the middle(ish) of the likely time spans, plus the consequent need to attend to the details of the annotation of the x-axis, a definite strain on the patience. So much for just "plot(x,y)" and the like, with just "datetick" for annotation. I've always wanted (for example) the "year" annotation to be placed in the <b>middle</b> of its year span, not under the tick marking its start. Perhaps now I shall grind through the requirements to achieve this, if it is possible...
|
Mon 27 Apr 2015 09:01:17 AM UTC, original submission:
Originally developed for matlab and works as expected. Under Octave, oddities, ruining the result. The data are electricity power measurements, half-hour averages, thus each datum is to be represented as a horizontal bar extending over its time span when just a few days are being covered - so the "stairs" style of plot.
Test data (Asample.csv) offers two day's worth, thus 96 values. Only 27 stairs appear. Some steps have small spikes up or down at stair boundaries, for instance between the fifth and sixth stair as shown. The greeen dots in the screengrab (Figure1Screengrab.jpg) are added debug stuff to show the first dozen values: plot(xx(1:12),yy(1:12)/GnashScale,'g.'); yet only three stairs are shown for those data.
When on the Figure 1 window, File>Save as>Asample.svg was selected (for the version without green dots), Inkscape shows four lines from various positions along the stairway to near 10 on the y-axis. Further, the stairway is different, showing 32 steps!
The stairs command is at line 448, stairs(xx,yy/GnashScale,colour) in file GnashPlot.m which is unfortunately rather large as it is indended to deal with mass plotting and offer various options. Two commands suffice for this problem:
Gnash Asample.csv
GnashPlot
The added debugging lines to reveal the xx and yy arrays (converted for readability into half-hour number, and megawatts rather than kilowatts - the /GnashScale) give results that look like proper numbers: no NaN for example.
Plot attempts for much larger data files (covering a decade of half-hourly data, say) seem to omit classes of the plottery (classes: for each day, a bar upper quartile to maximum, lower quartile to minimum, horizontal dash for the median; daily averages, weekly stairs) and the .svg attempts have many more than just four lines heading for the y-axis, but this could be due to altogether too many plot items.
Except for the debugging insertions, the .m files have been used via matlab for some years, though with incremental additions as annoyances became irksome...
|