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

 
 

bug #59695: Strange quiver plot with integer data type

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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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>
Project 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>
Project 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

Items that depend on this one: None found

 

Carbon-Copy List
  • -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)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    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.5