I have a 2D numpy array and I want to plot it in 3D. I heard about mplot3d but I cant get to work properly
Here\'s an example of what I want to do. I have an array with
You can find the answer in one of the examples of the Matplotlib gallery; the 3D examples are towards the end.
More generally, the Matplotlib gallery is a great first-stop resource, for finding how to do some plots.
The examples I looked at essentially work with three 2D arrays: one with all the x values, one with all the y values, and the last one with all the z values. So, one solution is to create the arrays of x and y values (with meshgrid()
, for instance).