Density grid plot rotated when given x and y values (Python)

Viewed 913

I have a grid density plot for a set of data points and when using matplotlib 2dhistogram to create a grid contour the resulting colour plot seems to be flipped in the vertical axis and rotated too. I can't see why this is the case but I have put my code below and will attach an image of the plots.

import numpy as np
from ngtsio import ngtsio
import math 
from statsmodels import robust
from numpy import mean, absolute
from astropy.stats import LombScargle
import matplotlib.pyplot as plt

gridx = np.linspace(0,frac,21)
gridy = np.linspace(0,1,21)

grid,_,_ = np.histogram2d(new_phase,binned_flux,bins=[gridx,gridy])

plt.grid(True)
plt.pcolormesh(gridx,gridy,grid)
plt.colorbar()

plt.grid()
plt.plot(new_phase,binned_flux,'r.',linestyle='None',markersize = markersize)
plt.ylim(0,1)
plt.xlim(0,frac)
plt.xlabel('Phase')

please note that frac is an array of (0.5,1.0,2.0) i.e. the limits seen in the 3 subplot x-axes and the code runs through each and plots in turn. enter image description here

Many thanks in advance!

1 Answers
Related