0

I'm trying to make a kdeplot graphic using some coordinates. Problem is that when I merge it with an image, the kdeplot rotates making it not to match the image. If I remove the line

plt.imshow(img)

The kdeplot shows the graphic correctly.

fig, ax = plt.subplots(figsize=(13.5, 8))
fig.set_facecolor("#23312b")
ax.patch.set_facecolor("#22312b")


plt.title("asd", color = "red", size=20)
#df.to_csv("prueba.csv", index = False)



coordenadasX = []
coordenadasY = []
for x in range(len(df)):
    coordenadasX.append(newdict[x][1])
    coordenadasY.append(newdict[x][2])

heatmap, xedges, yedges = np.histogram2d(coordenadasX, coordenadasY, bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

coordenadas = np.array([coordenadasX, coordenadasY])

img = cv2.imread('C:\\Users\\srjza\\Documents\\LeaguePython\\mapa.jpg')

ax = sns.kdeplot(
    x = coordenadasX, 
    y = coordenadasY, 
    thresh = False,
    n_levels=12,
    alpha=0.7,
    fill=True,
    color="red",
    legend=True
)

#plt.clf()
plt.scatter(coordenadasX, coordenadasY)
#plt.imshow(heatmap.T, extent=extent, origin='lower')
plt.imshow(img)
plt.show()

graphic

All the dots should match the right bottom corner.

mew
  • 9
  • 2

0 Answers0