This is strange, I hope someone can help me. I am trying to plot the density of my data using matplotlib heatmap, but for some reason my data is changing / rotating in a weird way. I have a scatter chart and then I use these points for density, but the image is not at all what should appear. For example, here is the original scatter plot that has the correct orientation:

Then here is my heatmap (note that the structure rotates 90 degrees counterclockwise from above, but the axis data is correct ... the numbers on the axes are automatically generated from the data, so if you just change the axes, the image is correct, but the numbers all off):

I just donโt see how this can be, because the procedure for parsing the data is identical to the one that was before when I just generated the scatter plot. I think it should be something like the heat map graph is encoded, but I donโt see where the breakdown can occur. I have already tried accounting for the built-in placement (upper left corner) for a heatmap, which does not solve the problem. The code is as follows (first, the entire parsing of the data):
import numpy as np from numpy import ndarray import matplotlib.pyplot as plt import matplotlib import atpy from pylab import * twomass = atpy.Table() twomass.read('/Raw_Data/IRSA_downloads/2MASS_GCbox2.tbl') hmag = list([twomass['h_m']]) jmag = list([twomass['j_m']]) hmag = np.array(hmag) jmag = np.array(jmag) colorjh = np.array(jmag - hmag) idx_c = (colorjh > -1) & (colorjh < 6)
Now here is the card code:
heatmap, xedges, yedges = np.histogram2d(colorjh[idx], hmag[idx], bins=500) extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] plt.clf() plt.imshow(heatmap, extent=extent) plt.xlabel('Color(JH)', fontsize=15)
I am new to Python, so the fewer the explanations, the more likely I will be able to use it for good use. Thanks for any help you can provide.