0

I want to compare two datasets having different numbers by doing the contour plot. What is the best way to compare it? I want to have the same level for two data so that I can compare easily as the number of two datasets is different.

For this case, I use seaborn KDE contour plot taking the same contour level/colour-bar to compare the data. How to do that? When I do plot together at one plot, it is just plotting independently with stacking on the surface of one plot. So, I am not able to compare it as one dataset contains more number than another dataset. Even when I use Plotly contour plot, I got different contour plot.

Here is the sample code for that import numpy as np import matplotlib.pyplot as plt from astropy.table import Table import seaborn as sb

data1=Table.read('data1.fits')
data2=Table.read('data2.fits')

X1=data1['ra']
Y1=data1['dec']
Z1=data1['redshift']


X2=data2['ra']
Y2=data2['dec']
Z2=data2['redshift']



fig = plt.figure(figsize=(12,10))
ax = fig.add_subplot(111,label='1')

k2=sb.kdeplot(X2,Y2,cmap='Reds',shade=False, shade_lowest=True,gridsize=500, cbar=True,annot = True)
k1=sb.kdeplot(X1,Y1,cmap='Blues',shade=False, shade_lowest=True,gridsize=500, cbar=True,annot = True)
ax.scatter(X2,Y2,s=0.8,color='Red')
ax.scatter(X1,Y1,s=0.8,color='blue')
ax.set_xlabel('RA')
ax.set_ylabel('DEC')
ax.set_xlim(349.5,354.3)
ax.set_ylim(-2,1.5)

Here the number of data1 is 397 and data2 is 1058. And the figure is given here. enter image description here

As we can see the Data1(Blue contour) has less number and it is contouring according to the data. I want to see the densest region among the two datasets. So, How to compare it by using same contour level and what to do with the smoothing value

John Singh
  • 79
  • 1
  • 2
  • 10
  • I'm not sure I completely understand what you are trying to accomplish, but would adding the two datasets together and plotting the sum help? – busybear Dec 17 '20 at 14:30
  • That may help: https://stackoverflow.com/questions/37374983/get-data-points-from-seaborn-distplot – Tarik Dec 17 '20 at 14:31
  • I would like to see the densest region but when I do the contour plot like this, it is plotting independently. In the fig, blue and red are different datasets. But when I plot, even the region let say A where it is dense in blue data only(so it has its own contour level high at this area) but it is very less dense when compared with the red(means red is very much dense in that region A). So, What I want is to have the same level for both data so it will help us to understand that the region is denser in red than blue in that area.(more contour around red than the blue at that region) – John Singh Dec 17 '20 at 14:44
  • Not completely clear about what you are askşing for? Do you want to have the two bars on the right to be the same? – Sinan Kurmus Dec 17 '20 at 15:01
  • Yes, Something like that. So, If red is denser in one region, it will show more level than blue. I just one to have the same bar for two datasets so it will be easier to compare between them. – John Singh Dec 17 '20 at 15:07

0 Answers0