0

For example, the code is shown as follows,

import numpy as np

import matplotlib.pyplot as plt

x = np.arange(-10,20,0.2)

y = 1.0/(1.0+np.exp(-x))

fig, [ax0, ax1] = plt.subplots(ncols=2, figsize=(8,4)) 

...

...

What is the meaning of this sentence mean:

fig, [ax0, ax1] = plt.subplots(ncols=2, figsize=(8,4)) 

I understand the right hand means plotting subplots and the number of columns is 2 and size of the figure is defined, but I do not understand what does the left hand side mean?

fig, [ax0, ax1] 

I think the meaning of it is not defining a function or a variable, so I want to know the meaning of it.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • 1
    it's unpacking, knowing that the function returns a tuple of an object and another tuple/list containing 2 elements. – Jean-François Fabre Jan 05 '18 at 20:41
  • 1
    @Jean-FrançoisFabre to be utterly pedantic, it returns an *iterable* with exactly two elements, the second element being itself an iterable with exactly two elements... ;) – juanpa.arrivillaga Jan 05 '18 at 20:59
  • you're absolutely right. I just felt I had to comment before searching & closing as duplicate. The original question is sooo detailed it's difficult to do better :) – Jean-François Fabre Jan 05 '18 at 21:01

0 Answers0