0

I was looking through how to smooth a 3d graph in Smooth surface Plot with Pyplot. In the answer portion, the user has a piece of code that looks like this:

np.mgrid[-1:1:80j, -1:1:80j]

I understand that np.mgrid creates a grid. I understand that the range for the x and y of the above grid would be from -1 to 1 for both axes. But I do not understand the 80j portion. Could someone please explain it to me?

Edit: For anyone else who stumbled on this question: 80j is an imaginary or complex number. np.mgrid takes the real portion of the value and creates that many points within the range (ends inclusive). See the link in one of the comments below. So this would create 80 points between -1 and 1.

  • 2
    See e.g. https://stackoverflow.com/q/48940544/3001761 - `80j` is an [imaginary number](https://en.wikipedia.org/wiki/Imaginary_number), `numpy` interprets an imaginary step for a slice as being the number of points you want. – jonrsharpe Nov 26 '20 at 14:09
  • 1
    80j portion means step length is a [complex number](https://numpy.org/doc/stable/reference/generated/numpy.mgrid.html). – Qiu Nov 26 '20 at 14:10
  • Thank y'all for answering my question. – Jules Stacy Nov 26 '20 at 14:12

0 Answers0