...I created some Cosmic Microwave Background data to plot as a Mollweide projection.
I need some help to find what is the package, the syntax to make a Mollweide plot.
> df0
# A tibble: 3,072 x 8
index ind x y z theta phi density
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 6144 0.23 0.00830 0.00830 0.230 0.0510 0.785 -0.124
2 6145 0.23 -0.00830 0.00830 0.230 0.0510 2.36 0.0613
3 6146 0.23 -0.00830 -0.00830 0.230 0.0510 3.93 -0.407
4 6147 0.23 0.00830 -0.00830 0.230 0.0510 5.50 -0.527
5 6148 0.23 0.0217 0.00897 0.229 0.102 0.393 -1.32
6 6149 0.23 0.00897 0.0217 0.229 0.102 1.18 -1.49
7 6150 0.23 -0.00897 0.0217 0.229 0.102 1.96 -0.0184
8 6151 0.23 -0.0217 0.00897 0.229 0.102 2.75 0.761
9 6152 0.23 -0.0217 -0.00897 0.229 0.102 3.53 0.205
10 6153 0.23 -0.00897 -0.0217 0.229 0.102 4.32 -0.357
I am returning to R just to create this shinyapp. I need to plot (theta, phi) with the color controlled by density.
This is the current state of the shinyapp
https://qsnyc.shinyapps.io/UniverseMap/?_ga=2.263388808.509163910.1601941058-1505942256.1600516222
I don't see it as useful, so I need to create the Mollweide plot.
Any help would be welcomed.
Thanks
PS - This is the python code to generate the data if needed
import healpy as hp
import numpy as np
import pandas as pd
from matplotlib import cm
from scipy.stats import norm
nside=16
xx, yy, zz = hp.pix2vec(nside=nside, ipix=np.arange(hp.nside2npix(nside)))
ones = np.ones(xx.shape[0])
theta, phi = hp.pix2ang(nside=nside, ipix=np.arange(hp.nside2npix(nside)))
df = pd.DataFrame(np.empty([0,7]), columns=["ind","x","y","z","theta","phi","density"])
df1 = pd.DataFrame(np.empty([0,7]), columns=["ind","x","y","z","theta","phi","density"])
for r in np.linspace(0.01, 1.0, 10):
df.ind=r*ones
df.x=xx*r
df.y=yy*r
df.z=zz*r
df.theta=theta
df.phi=phi
df.density=np.random.rand(xx.shape[0])
title="Radius={}".format(r)
mu, sigma = norm.fit(df.density)
df.density =(df.density-mu)/sigma
hp.mollview(df.density.squeeze(), title=title, min=-4 * sigma,
max=4 * sigma, unit="K", cmap=cm.RdBu_r)
df1 = pd.concat([df1,df])
df1=df1.reset_index()
df1["index"]=df1.index
df1.to_feather("df.feather")
and here the selection by "ind" in the R script:
library(feather)
library(mapproj)
library(ggpubr)
df <- feather::read_feather('./df.feather')
# https://cran.r-project.org/web/packages/ebirdst/vignettes/ebirdst-intro-mapping.html
ind <- unique(df$ind)
df0 <- df[df$ind==ind[3],]
x <- df0$theta*180/pi
y <- df0$phi*180/pi
mapproject(x, y,"mollweide")
ggscatter(df0, x="x",y="y",color="density", pallete="jco", main="Univerrse Map")
I am trying to use ggscatter but can't figure out how to choose the projection