bugGNU Octave - Bugs: bug #40898, scatter3 needs better input...

 
 

bug #40898: scatter3 needs better input validation

Submitted by:  None
Submitted on:  Sat 14 Dec 2013 09:54:47 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Ralph GoodwinOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Tue 24 Dec 2013 05:44:04 AM UTC, comment #10:

I added input validation on the default branch in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/d6aaf821cf8f). It will be a part of the 4.4 release, or you can grab the m-file from Mercurial source control to see the changes.

Rik <rik5>
Project Administrator
Thu 19 Dec 2013 02:45:56 PM UTC, comment #9:

It's helpful to have one bug for each issue so I opened a new bug report (bug #40971) to cover the second issue you found. The easiest workaround is to use the FLTK toolkit

I don't know if this works on the Windows 3.6.4 release though. It certainly will for 3.8.

Rik <rik5>
Project Administrator
Thu 19 Dec 2013 01:14:39 PM UTC, comment #8:

Thanks for helping me with this. I think there is another bug in scatter/scatter3. An error is generated if one is specifying individual point colors and all of the points happen to be the same color. If all of the points are close to the same color, there is no error but there is also no graph. If the colors are more different, then everything works as expected.

Finally, what specific values of tiny cause various behaviors seems to depend on what else I have done in the current Octave session. Sorry. My exact test code is below. Try .1, 1e-6 and 0.

Here is the error I see.

20>scatter3test
n = 101
tiny = 0
error: vertical dimensions mismatch (101x3 vs 1x1)
error: called from:
error: C:\Software\Octave-3.6.4\share\octave\3.6.4\m\plot\private\__go_draw_ax
es__.m at line 1054, column 36
error: C:\Software\Octave-3.6.4\share\octave\3.6.4\m\plot\private\__go_draw_fi
gure__.m at line 167, column 19
error: C:\Software\Octave-3.6.4\share\octave\3.6.4\m\plot\__gnuplot_drawnow__.
m at line 86, column 5
21>

here is the test code

clear
clf
n=101
x = rand (n,1);
y = rand (n,1);
z = rand (n,1);
s=20*rand(n,1);
tiny=0
c=abs(0.5(ones(n,3)-tinyrand(n,3)));
% scatter3 (x, y, z, s, c, "s");
scatter (x, y, s, c, "s");

Anonymous
Tue 17 Dec 2013 07:07:03 PM UTC, comment #7:

You want to invoke scatter3 with an Nx3 color matrix. However the code

turns the matrix into a column vector. The correct way to call the function is

In fact, x,y,z,s are already column vectors so there's no point in using '(:)' to change them to column vectors again. You could just write

which looks cleaner.

Rik <rik5>
Project Administrator
Tue 17 Dec 2013 06:15:31 PM UTC, comment #6:

I am getting an Nx3 matrix from rand(N,3) (Octave 3.6.4, windows).
Isn't this what I am supposed to send to scatter3?

1>k=rand(100,3);
2>whos
Variables in the current scope:

Attr Name Size Bytes Class
==== ==== ==== ===== =====
ans 1x24 24 char
k 100x3 2400 double

Total is 324 elements using 2424 bytes

Ralph

Anonymous
Sun 15 Dec 2013 10:44:07 PM UTC, comment #5:

In fact, I don't see any input validation at all. I changed the y vector to have one less vertex than the others and instead of warning about the difference it failed with

Rik <rik5>
Project Administrator
Sun 15 Dec 2013 10:43:06 PM UTC, comment #4:

Here is the error I am seeing. (My work around is to plot the data in batches of 100.) ---Ralph

3>version
ans = 3.6.4
4> clear
5> clf
6> n=101
n = 101
7> x = rand (n,1);
8> y = rand (n,1);
9> z = rand (n,1);
10> s=20*rand(n,1);
11> c=rand(n,3);
12> scatter3 (x(:), y(:), z(:), s(:), c(:), "s");
error: _scatter_: A(I,J): row index out of bounds; value 269 out of bound 101
error: called from:
error: C:\Software\Octave-3.6.4\share\octave\3.6.4\m\plot\private\__scatter__.
m at line 214, column 13
error: C:\Software\Octave-3.6.4\share\octave\3.6.4\m\plot\scatter3.m at line 6
8, column 11
12>

Anonymous
Sun 15 Dec 2013 10:37:57 PM UTC, comment #3:

The sample code is not calling scatter3 correctly. I changed the Summary for the report to "scatter3 needs better input validation". The error message currently given is too obscure.

From the documentation,

The calling code is:

which means that C is a column vector of size [3*N, 1] which doesn't correspond to any of the allowed formats.

If the function is called with an Nx3 matrix (1 RGB color for each point) then it works.

Rik <rik5>
Project Administrator
Sun 15 Dec 2013 08:54:51 PM UTC, comment #2:

Confirmed on Linux (Mageia 2) with Octave-3.8.0-rc1 and Windows (MinGW) with Octave-3.7.7 (from Nov. 30).

Rik, adapt n=100 to n=101 and try again, please.

It works with n=100; but with n=101 I get:

With gnuplot I get slightly different numbers:

On Linux I get yet other index-out-of-bounds numbers.

(Release set to dev)

Philip Nienhuis <philipnienhuis>
Project Member
Sun 15 Dec 2013 03:05:20 PM UTC, comment #1:

The code works for me. This is with Ubuntu 12.04, Octave 3.6.4, and gnuplot 4.6.2. It might be a problem with the Windows version of either Octave or gnuplot. Perhaps you could include the error message you were seeing.

Rik <rik5>
Project Administrator
Sat 14 Dec 2013 09:54:47 PM UTC, original submission:

scatter3 fails when asked to set simultaneously individual point sizes and colors for data sets with more than 100 points. The following code illustrates the issue if n>100

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 24 Dec 2013 05:44:04 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sun 15 Dec 2013 10:37:57 PM UTCrik5CategoryPlotting with gnuplot=>Plotting
      Summaryscatter3 failure=>scatter3 needs better input validation
    Sun 15 Dec 2013 08:54:51 PM UTCphilipnienhuisStatusWorks For Me=>Confirmed
      Release3.6.4=>dev
      Operating SystemMicrosoft Windows=>Any
    Sun 15 Dec 2013 03:05:20 PM UTCrik5StatusNone=>Works For Me

    Back to the top


    Powered by Savane 3.1-cleanup1