0

I am attempted to generate the Z values for a contour plot

x = np.linspace(s_T,e_T,num=graph_density)
y = np.linspace(s_P,e_P,num=graph_density)

x,y = np.meshgrid(x,y)

I have generated an x,y mesh grid to make up my x and y values of the plot. But now i need to take this mesh grid and solve the pairings for a Z value and put it into a matrix. I can think of a couple of brute force ways to do this using M and N "for loops" but I was wondering if there was a more efficient way to do this?

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Joe Wilson
  • 21
  • 4
  • For some values it may be as simple as `z=x*y`. But generally we/you need know something about how `z` depends on x and y. – hpaulj Sep 12 '21 at 02:00
  • So for my case, Z is dependent on a function that takes a pairing of x and y values such as Z = fn(x,y) which outputs a single value. Im looking for a good way to efficiently take the mesh matrix and solve for every pairing of x and y and place those Z values in a matrix for the contour plot – Joe Wilson Sep 12 '21 at 02:43
  • 1
    As long as your `fn` only handles one value at a time, there isn't anything you can do to make it more "efficient". The iteration method and collection of values will only be a minor part of the whole cost. – hpaulj Sep 12 '21 at 03:17

0 Answers0