I have the following lists:
x_list = [7,10,3,9,9]
y_list = [2,5,1,3,2]
z_list = [4,1,5,2,3]
For each x value and y value there is a zvalue. For example: x=7and y=2have the zvalue of 4.
I would like to convert this into a matrix such as:
… to be able to create a matrix-plot with the correct x- and y- axis and a colorbar (colorbar is missing here, and it would be nice to have the zero values as black color):
It is rather straightforward to do in Excel, but I am having difficulties doing it in python, since I am quite new to matplotlib.
Edit
I might use plt.imshow() to make the plot


NumPy's
uniqueandmeshgridfunctions are your friends here to set up the proper grid from your coordinates. Then, you just need to find the proper indices in the resultingXandY, that correspond to your coordinates. Finally, in some all-zeroZmatrix with the same dimensions asXandY, you can set the elements at the just found indices to your originalzdata.Here's some code:
And, the output is:
Regarding the plotting: I can't think of a Matplotlib function to create a plot similar to the shown. So, maybe give an additional hint, which function you have in mind.
Hope that helps!