I could not remotely figure out how to define a plot over a triangular region in matplotlib. That is the first problem I have.
As a workaround, I thought to define the function using a conditional expression, to avoid problems where the function is not defined.
def f(x,y):
for a in x:
for b in y:
if a>b:
g = log(a-b)
else:
g = 0
return
x = np.linspace(0.1, 1000, 30)
y = np.linspace(0.1, 3, 30)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
but I get the error message
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
which at least made me understand (sort of) what meshgrid does.
To summarise:
1) what is the neatest way to plot a function over a triangle?
2) what is the advantages of plotting over a meshgrid, instead of defining a single array as ([X1,Y1], [X1,Y2], ..., [X1,YN], [X2, Y1], [X2, Y2], ..)?
Thanks a lot