I am trying to plot Two-dimensional distribution with Gaussian smoothing for all the data points. Here is my sample data. I would like to plot like this paper figure.
[Two-dimensional distribution of Hα emitters(galaxies). The small circles indicate the positions of Hα emitters. The colored contours indicate 1 σ, 1.5 σ, 2 σ, 3 σ, 4 σ, 5 σ above the mean density distribution computed with all member galaxies (i.e., the photo-z-selected sample and Hα emitters). Here we apply Gaussian smoothing for all the data points with σ ∼ 0.75 Mpc, and co-add the tail of the Gaussian wing at each position. The large gray circles show the object masks; we show only large masks with radius of >2΄ for clarity. (Color online)]
I am trying to plot the same plot with my data. But I am not able to plot like this.
Here is my code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
import scipy as sp
import scipy.ndimage
from astropy.table import Table
import branca
import pandas as pd
%matplotlib inline
#DATA
data=Table.read('s_data.fits')
density_mean=np.mean(data['density'])
std=np.std(data['density'])
vmin = density_mean+std
vmax = density_mean+(5*std)
levels = len(colors)
cm = branca.colormap.LinearColormap(colors, vmin=vmin, vmax=vmax).to_step(levels)
x_orig = data['ra']
y_orig = data['dec']
z_orig = data['density']
# Make a grid
x_arr = np.linspace(np.min(x_orig), np.max(x_orig), 500)
y_arr = np.linspace(np.min(y_orig), np.max(y_orig), 500)
#WHEN I CHANGE THE VALUE FROM 500 to ANOTHER IT DOESN'T COVER ALL THE AREA. WHAT WILL BE THE APPROPRIATE VALUE FOR THIS?
x_mesh, y_mesh = np.meshgrid(x_arr, y_arr)
# Grid the values
z_mesh = griddata((x_orig, y_orig), z_orig, (x_mesh, y_mesh), method='linear')
# Gaussian filter the grid to make it smoother
sigma = [5, 5]
z_mesh = sp.ndimage.filters.gaussian_filter(z_mesh, sigma, mode='constant')
# Create the contour
plt.plot(data['ra'], data['dec'], 'ko', markersize=1,alpha=1)
plt.text(352.33,0.135, 'CL1',fontsize=15) #CL1 coordinate
plt.text(352.096,0.390, 'CL2', fontsize=15) #CL2 coordinate
plt.contourf(x_mesh, y_mesh, z_mesh, levels, alpha=0.7, colors=colors, linestyles='None',
vmin=vmin, vmax=vmax)
#plt.colorbar()
plt.gca().invert_xaxis()
I know something is wrong with my data. Kindly help to get the proper figure like given in the paper. Thank you.