bugGNU Octave - Bugs: bug #59695, Strange quiver plot with integer...

 
 

bug #59695: Strange quiver plot with integer data type

Submitter:  None
Submitted:  Tue 15 Dec 2020 11:25:36 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  Berk Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.1.0
Operating System:  * Any Fixed Release:  9.1.0
Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 11 May 2023 03:38:36 AM UTC, comment #5: 

two weeks without any complaints on this patch. closing as fixed.

Nicholas Jankowski <nrjank>
Group Member
Thu 27 Apr 2023 12:13:42 AM UTC, comment #4: 

patch pushed to fix this in `__quiver__`. they should now plot properly if the numeric inputs are types other than double. this includes x, y, u, v, and scale factor, even though matlab errors if scale factor is anything other than a double or 'off'. (this patch also enables 'off' work)

https://hg.savannah.gnu.org/hgweb/octave/rev/ada96a467a28

Nicholas Jankowski <nrjank>
Group Member
Thu 17 Dec 2020 09:28:07 PM UTC, comment #3: 

It's pretty trivial to cast the inputs to floating point with double() if we want to.  If we did this, we should probably also take a look at all the other plot functions and verify whether we want to do the same thing.

I tried this in Matlab


h = plot (int8(1:5), int8(1:5), 'o-')
class (get (h, 'xdata'))


and it returns "int8" so the plot function doesn't cast its inputs.

Rik <rik5>
Group administrator
Thu 17 Dec 2020 08:20:07 PM UTC, comment #2: 

@Rik: Matlab indeed does cast input data to double and store them as such. I ran the following code in Matlab and it returned "double" for both UData and VData.


[X,Y] = meshgrid (0:6, 0:6);
U = 0.25*X;
V = 0.5*Y;
obj = quiver (X, Y, int16 (U), int32 (V), 0);
class (obj.UData)
class (obj.VData)


Pantxo Diribarne <pantxo>
Group Member
Wed 16 Dec 2020 01:44:26 AM UTC, comment #1: 

The quiver function is not designed for integer data types which have specific rules for multiplication, division, addition, subtraction when used in combination with floating point numbers.  Instead, use one of the functions which removes the fractional part from the floating point number without changing the type.  For example, fix(), floor(), ceil(), or round().  Using


quiver(X,Y, round (U), round (V),0)


should do what you want.

Matlab handles it by converting whatever data you give it to floating point with double() before plotting it.  I suppose Octave could do the same thing.

Rik <rik5>
Group administrator
Tue 15 Dec 2020 11:25:36 PM UTC, original submission:  



[X,Y] = meshgrid(0:6,0:6);
U = 0.25*X;
V = 0.5*Y;

quiver(X,Y,U,V,0)
figure, quiver(X,Y,int16(U),int16(V),0)

First one gives the expected plot. Second one produces a plot but every line segment is connected to the origin. I'm aware the second plot isn't supposed to be identical to the first one but this behavior seems like a bug.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50485:  normal.png added by None (68KiB - image/png)
file #50486:  with_int_data.png added by None (202KiB - image/png)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-05-11 nrjank StatusReady For Test Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0
    2023-04-27 nrjank StatusNone Ready For Test
    2023-04-27 nrjank Planned ReleaseNone 9.1.0
    2023-04-26 rik5 Dependencies- bugs #64078 is dependent
    2020-12-17 rik5 Operating SystemMicrosoft Windows Any
    2020-12-15 None Attached File- Added normal.png, #50485
        Attached File- Added with_int_data.png, #50486

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code