bugGNU Octave - Bugs: bug #37420, plot(x,y) is broken for uint8

 
 

bug #37420: plot(x,y) is broken for uint8

Submitter:  Hans-Jürgen Greif <grepi>
Submitted:  Fri 21 Sep 2012 08:07:12 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  H.-J.Greif Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 22 Sep 2012 06:31:50 PM UTC, comment #4: 

Ok, I'm closing the ticket.  It can be reopened in needed.

Ben Abbott <bpabbott>
Group Member
Sat 22 Sep 2012 03:31:08 PM UTC, comment #3: 

it works on subsequent changeset,
you can change the status to fixed

marco atzeri <matzeri>
Sat 22 Sep 2012 12:48:52 AM UTC, comment #2: 

I found the problem/feature.

When combining a double() with a uint8(), the uint8() type has precedence.  Thus, class ([uint8(1), double(1024)]) is converted to uint8, whose largest number is 255.

Ive pushed a changeset

http://hg.savannah.gnu.org/hgweb/octave/rev/283cada76dd6

Ben Abbott <bpabbott>
Group Member
Fri 21 Sep 2012 08:56:38 PM UTC, comment #1: 

This bug is only present when using the gnuplot backend, and is present in the developers sources.

Using the script below, I produced the attached plot stream to gnuplot (34720.gp).


close all
graphics_toolkit gnuplot
A = imread ('untersuche.png');
y = A (1, :);
plot (y)
drawnow ("aqua", "/dev/null", false, "34720.gp")


I don't see anything wrong with the ascii content, and suspect the problem is hidden in the binary part.  After experimenting, I found that converting "y" to a double gives the desired result.  So, the following works for me.


close all
graphics_toolkit gnuplot
A = imread ('untersuche.png');
y = A (1, :);
plot (double (y))


It doesn't fix the underlying bug, but a superficial fix (below) is to convert the {x,y,z}data to doubles.


diff --git a/scripts/plot/private/__go_draw_axes__.m b/scripts/plot/private/__go_draw_axes__.m
--- a/scripts/plot/private/__go_draw_axes__.m
+++ b/scripts/plot/private/__go_draw_axes__.m
@@ -441,6 +441,15 @@
     while (! isempty (kids))

       obj = get (kids(end));
+      if (isfield (obj, "xdata") && ! isempty (obj.xdata))
+        obj.xdata = double (obj.xdata);
+      end
+      if (isfield (obj, "ydata") && ! isempty (obj.ydata))
+        obj.ydata = double (obj.ydata);
+      end
+      if (isfield (obj, "zdata") && ! isempty (obj.zdata))
+        obj.zdata = double (obj.zdata);
+      end

       if (isfield (obj, "units"))
         units = obj.units;




(file #26613)

Ben Abbott <bpabbott>
Group Member
Fri 21 Sep 2012 08:07:12 PM UTC, original submission:  

Hello,

in all octave versions > 3.6  I have found a severe plot bug:

A= imread('untersuche.tif'); % chess board

y=A(1, 1:537);

plot(1:537, y)


plot in octave end up at column 265.

plot-command in all Matlab versions > 2007b is ok.


Hans-Jürgen Greif <grepi>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #26613:  34720.gp added by bpabbott (11KiB - application/octet-stream - gnuplot plot stream)
file #26610:  octave_3_6_0_plot_result.png added by grepi (25KiB - image/png - untersuche.tif in png converted because size)
file #26611:  untersuche.png added by grepi (5KiB - image/png - untersuche.tif in png converted because size)
file #26612:  matlab_2007b_plot_result.png added by grepi (37KiB - image/png - untersuche.tif in png converted because size)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by matzeri (Posted a comment)
  • -email is unavailable- added by bpabbott (Updated the item)
  • -email is unavailable- added by grepi (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 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-09-22 bpabbott StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2012-09-22 bpabbott Item GroupNone Incorrect Result
        StatusConfirmed Ready For Test
        Assigned toNone bpabbott
    2012-09-21 bpabbott Attached File- Added 34720.gp, #26613
        CategoryPlotting Plotting with gnuplot
        StatusNone Confirmed
        Release3.6.2 dev
        Operating SystemMac OS Any
        Summaryplot(x,y) plot(x,y) is broken for uint8
    2012-09-21 grepi Attached File- Added octave_3_6_0_plot_result.png, #26610
        Attached File- Added untersuche.png, #26611
        Attached File- Added matlab_2007b_plot_result.png, #26612

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code