ThunderFlashxShanuLover - 1 year ago 76

Python Question

So I have a N-dimensional array of values, let's call it A. Now, I can plot this in a contour map, with coordinate axes X and Y, using

`plt.contourf(X,Y,A)`

Now, I have to carry out a mapping of these points to another plane, so, basically another set of coordinates. Let the transformation be

`X - X1`

Y - X1

Now, each point with magnitude "I" in matrix A at (X,Y) is at (X- X1, Y - Y1). I can plot this using

`plt.contourf(X-X1, Y-Y1,A)`

My question is, how do I index the array A such that I obtain an array B where the indexing corresponds to X-X1 and Y-Y1 instead of X and Y so that I can plot it directly using the following

`plt.contourf(X,Y,B)`

Thanks!

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

A friend helped me out with this. Seems to work perfectly.

```
for ii in xrange(A.shape[1]):
for jj in xrange(A.shape[0]):
H = ii - alpha_x[jj,ii]
J = jj - alpha_y[jj,ii]
if H >= 0 and H<= A.shape[1] and J >= 0 and J <= A.shape[0]:
B[J,H] = B[J,H] + A[jj,ii]
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**