Menu

#1932 imaginary component of array value lost during plot

None
closed
nobody
None
2017-06-16
2017-06-04
No

Example of failure:

#
# Imaginary component is lost when array element value
# is referenced as $2 in a plot command
#
array A[4] = [  {0.,1.}, {1.,0.}, {0,-1.}, {-1.,0.} ]

set xrange [-2:2]
set yrange [-2:2]

plot A using (real($2)):(imag($2)):(sprintf("%d"),$1) with labels

It does work if you instead say

plot sample [i=1:4:1] '+' using (real(A[i])):(imag(A[i]))

so this has something to do with the $ operator

Discussion

  • Hans-Bernhard Broeker

    gnuplot datafiles have never been capable of holding complex numbers, so it's no surprise that neither the $ operator nor the column() function can read complex numbers. I think this qualifies not as a bug, but as a feature request.

     

    Last edit: Hans-Bernhard Broeker 2017-06-04
    • Ethan Merritt

      Ethan Merritt - 2017-06-05

      Yeah. But upon reflection I don't think it's necessary. There is a fairly clean alternative syntax that already works, though I didn't think of the first time around.

      plot A using (real(A[$1]):(imag(A[$1]))
      

      I'll make sure it's documented somewhere and used in a demo.

       
  • Ethan Merritt

    Ethan Merritt - 2017-06-16
    • status: open --> closed
    • Group: -->
    • Priority: -->
     

Log in to post a comment.