bugGNU Octave - Bugs: bug #44936, stairs(x,y,'r'); omits many stairs...

 
 

bug #44936: stairs(x,y,'r'); omits many stairs (!) and has spikes; save as .svg introduces odd lines.

Submitter:  None
Submitted:  Mon 27 Apr 2015 09:01:17 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  Nicky McLean Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.2
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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.

Nicky McLean <dinosaur>
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...

Nicky McLean <dinosaur>
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...

Nicky McLean <dinosaur>
Mon 27 Apr 2015 10:37:16 AM UTC, comment #2: 

Here's an even older bug report:
https://savannah.gnu.org/bugs/?32980

Philip Nienhuis <philipnienhuis>
Group Member
Mon 27 Apr 2015 10:36:01 AM UTC, comment #1: 

This is actually a duplicate, see e.g.,
https://savannah.gnu.org/bugs/?33748
(there are several other bug reports, all boiling down to the same issue: OpenGL working with single precision.)

It'll work better with gnuplot:

graphics_toolkit gnuplot

Philip Nienhuis <philipnienhuis>
Group Member
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...

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #33801:  Asample.csv added by None (6KiB - text/csv - I can't find any other grumble about 'stairs', but perhaps it is not so popular.)
file #33802:  Asample.svg added by None (11KiB - image/svg+xml - I can't find any other grumble about 'stairs', but perhaps it is not so popular.)
file #33803:  Figure1Screengrab.jpg added by None (64KiB - image/jpeg - I can't find any other grumble about 'stairs', but perhaps it is not so popular.)
file #33804:  GnashPlot.zip added by None (36KiB - application/octet-stream - I can't find any other grumble about 'stairs', but perhaps it is not so popular.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dinosaur (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-27 philipnienhuis StatusNone Duplicate
        Open/ClosedOpen Closed
    2015-04-27 None Attached File- Added Asample.csv, #33801
        Attached File- Added Asample.svg, #33802
        Attached File- Added Figure1Screengrab.jpg, #33803
        Attached File- Added GnashPlot.zip, #33804

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code