I have a simulation tool which gives me temperature arrays as results. These temperature arrays are in each timestep 1D arrays. To visualize them (I've got alot of these temperature arrays which each represent a different part of my environment I simulate) I want to plot them with matplotlib. Since the parts represented by these arrays have different shapes, I need to plot the temperature arrays in these shapes and have the temperature on the Z-axis with a colorbar.
For my 2D-arrays this works great using a pcolormesh
plot, but lines which are not horizontal or vertical will be shown aliased when plotted. Setting antialiased=True
will help with that but instead produce big "blobs" which don't really look nice.
Is there any way to make the lines less "blobby" when using pcolormesh
?
My minimum working examples are below:
# temperature array
temp = np.arange(20, dtype=np.float64) + 25
# x and y vector along vertices (0, 0), (5, 15), (12, 16) and (0, 20):
x_vec = np.concatenate((np.linspace(0, 5, 7, endpoint=False), np.linspace(5, 12, 4, endpoint=False), np.linspace(12, 0, 9)))
y_vec = np.concatenate((np.linspace(0, 15, 7, endpoint=False), np.linspace(15, 16, 4, endpoint=False), np.linspace(16, 20, 9)))
# make diagonal matrix from temp for plotting:
t_dia = np.diag(temp)
# set 0 to nan for correct colorbar in pcolormesh:
t_dia[t_dia == 0] = np.nan
# and now plot pcolormesh:
fig2 = mp.figure()
ax2 = fig2.gca()
surf2 = ax2.pcolormesh(x_vec, y_vec, t_dia, linewidth=10, antialiased=True, edgecolors='None')
fig2.colorbar(surf2)
Thanks for your help in advance! (Since I'll be in the weekend now, I most probably won't be able to answer until monday.)