title: Plotting a function of two variables that includes a vector inside
body: <p>I have the following problem and this is the minimal example:</p>
  
  <pre><code>import numpy as np
  def f1(x,y,scal):
      return np.exp(-(scal-x)/y)
  def f2(x,y,vec):
      return np.sum(np.exp(-(vec-x)/y))
  
  inputvec = np.arange(1,10,1)
  
  x = np.arange(10)
  y = np.arange(1,8,1)
  X,Y = np.meshgrid(x,y)
  Z1 = f1(X,Y,20)
  print Z1
  Z2 = f2(X,Y,inputvec)
  </code></pre>
  
  <p>I want to 3D plot the function f2, so this is why I try the meshgrid thing. The error is:</p>
  
  <pre><code>ValueError: operands could not be broadcast together with shapes (9,) (7,10) 
  </code></pre>
  
  <p>It is even clear to me why this is the case, python would I think like to do something like f1, so that Z1 can be a grid answer which you can plot. But what if I use a vector in my function and the very nasty sum operation.</p>
  
  <p>Question: How can I change my function f2 to get around this problem, or is there a different way to (3D, Contour, etc..) plot f2 without going via the meshgrid way?</p>
  
  <p>Thanks a lot!</p>