1

I have a [128x128x128] array. From this I need to plot 1 single plane, i.e., the central plane along the z-axis, so I will have to use the array in the form A[:,:,64].

Do you know which commands should I type in order to get this contour plot?

1 Answers1

0

Let's say you have an array like this one:

import numpy as np
import matplotlib.pyplot as plt

A = np.random.rand(128, 128, 128)

A.shape
#Output:
(128, 128, 128)

Then you take out one plane by index:

A[:, :, 64].shape
#Output:
(128, 128)

When plotting with plt.contourf(), [X, Y] arguments are optional, so if you want to plot just one array along Z-axis, just pass the array you selected as an argument:

plt.contourf(ndarray[:, :, 64])
plt.show()

And you get this as an output:

enter image description here

Nikita Shabankin
  • 609
  • 8
  • 17