# How do I apply some function to a Python meshgrid?

PythonMatplotlibServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Meshgrid − Coordinate matrices from coordinate vectors.

Let's take an example to see how we can apply a function to a Python meshgrid. We can consider two lists, x and y, using numpy vectorized decorator.

## Example

import numpy as np
@np.vectorize
def foo(a, b):
return a + b
x = [0.0, 0.5, 1.0]
y = [0.0, 1.0, 8.0]
print("Function Output: ", foo(x, y))

## Output

Function Output: [0. 1.5 9. ]
Updated on 08-May-2021 09:25:51