[Scilab-users] Why plot doesn't work on integers

classic Classic list List threaded Threaded
3 messages Options
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Why plot doesn't work on integers


Dear all,

I know it is better to use plot2d, but I wonder why plot works differently from plot2d when one of the variables is integer.

Consider this code

  // Generate x axis with real (double) numbers
  x = (1:20)/20

  // Generate y axis with random integers
  y = iconvert(100*rand(1,20),2)

  // Plot y vs x
  plot(x, y)

The plot represents x vs its index, which is not the intended behavior. Replacing plot(x,y) with plot2d(x,y) we get the correct plot.

The documentation of both plot and plot2d requires "real" matrix or vector. It seems that plot takes it a bit too literally (as a data type) while plot2d adheres to the mathematical meaning of "real" (considering integer numbers as a subset of real numbers).

Is there a fundamental reason for this?

The problem arises when one retrieves integers from a file without converting them to double (which requires much more memory).

Regards,

Federico Miyara


Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Why plot doesn't work on integers

Hello Federico,

Thanks for pointing this issue.
It is clearly a bug. It occurs since the earliest ages of Scilab.
It will be fixed ASAP.

Regards
Samuel

Le 02/02/2019 à 09:42, Federico Miyara a écrit :

Dear all,

I know it is better to use plot2d, but I wonder why plot works differently from plot2d when one of the variables is integer.

Consider this code

  // Generate x axis with real (double) numbers
  x = (1:20)/20

  // Generate y axis with random integers
  y = iconvert(100*rand(1,20),2)

  // Plot y vs x
  plot(x, y)

The plot represents x vs its index, which is not the intended behavior. Replacing plot(x,y) with plot2d(x,y) we get the correct plot.

The documentation of both plot and plot2d requires "real" matrix or vector. It seems that plot takes it a bit too literally (as a data type) while plot2d adheres to the mathematical meaning of "real" (considering integer numbers as a subset of real numbers).

Is there a fundamental reason for this?

The problem arises when one retrieves integers from a file without converting them to double (which requires much more memory).

Regards,

Federico Miyara


Libre de virus. www.avast.com


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: Why plot doesn't work on integers


Thank you, I'm glad to help a little bit improve this great software.

Regards,

Federico Miyara

On 02/02/2019 17:29, Samuel Gougeon wrote:
Hello Federico,

Thanks for pointing this issue.
It is clearly a bug. It occurs since the earliest ages of Scilab.
It will be fixed ASAP.

Regards
Samuel

Le 02/02/2019 à 09:42, Federico Miyara a écrit :

Dear all,

I know it is better to use plot2d, but I wonder why plot works differently from plot2d when one of the variables is integer.

Consider this code

  // Generate x axis with real (double) numbers
  x = (1:20)/20

  // Generate y axis with random integers
  y = iconvert(100*rand(1,20),2)

  // Plot y vs x
  plot(x, y)

The plot represents x vs its index, which is not the intended behavior. Replacing plot(x,y) with plot2d(x,y) we get the correct plot.

The documentation of both plot and plot2d requires "real" matrix or vector. It seems that plot takes it a bit too literally (as a data type) while plot2d adheres to the mathematical meaning of "real" (considering integer numbers as a subset of real numbers).

Is there a fundamental reason for this?

The problem arises when one retrieves integers from a file without converting them to double (which requires much more memory).

Regards,

Federico Miyara


Libre de virus. www.avast.com


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users