I would like to create a contourf
plot from matrix 24x20 from dataframe like below scenario:
The snippet of my code is:
fig, ax = plt.subplots(nrows=1, ncols=3 , figsize=(20,10))
plt.subplot(131)
xlist = np.linspace(0, 20, 20)
ylist = np.linspace(0, 24, 24)
X, Y = np.meshgrid(xlist, ylist)
plt.contourf(X, Y, df3, cmap="coolwarm" )
plt.gca().invert_yaxis()
plt.axis('off')
Problem1 is I'm not sure why plot of 'A'
printed inversely and I have to use plt.gca().invert_yaxis()
based on this answer in order to invert it. I noticed that In 7 is mentioned: plt.imshow()
by default follows the standard image array definition where the origin is in the upper left, not in the lower left as in most contour plots. Is it the reason behind of that or am I doing something wrong?
Problem2 I would like to divide matrix into 8 small ones by drawing 4 white lines but wasn't possible by using ax.axvline(x=10, color='w',linewidth=1.5)
.
Based on In 7 it seems likewise plt.imshow()
doesn't accept an x and y grid, so it must manually specify the extent [xmin, xmax, ymin, ymax] of the image on the plot. Is there any idea to accomplish that?
Problem3 What's the benefit of Interpolation using scipy.interpolate.griddata
or Non-gridded contour using tricontour()
or this approach in this answer in my case?
Problem4 when interpolation='nearest'
is useful? I noticed the here it's used for finding contour
Note The matrix which has 480 values is available in .csv
file : here
Expected result will be like bellow picture: