Commit 1a48a55e authored by Mihai Baltac's avatar Mihai Baltac
Browse files

added mollview heatmap

parent 7513daa3
......@@ -23,12 +23,12 @@ class Line(_PlotlyWrapper):
class Axis(_PlotlyWrapper):
def __init__(self, text=None, font='', color='', log=False, aspect_ratio=None):
def __init__(self, text=None, font='', color='', log=False, show_grid=True):
self.text = text
self.font = font
self.color = color
self.log = log
self.aspect_ratio = aspect_ratio
self.show_grid = show_grid
def _to_plotly(self):
ply_object = dict()
......@@ -42,5 +42,6 @@ class Axis(_PlotlyWrapper):
))
if self.log:
ply_object['type'] = 'log'
if not self.show_grid:
ply_object['showgrid'] = False
return ply_object
......@@ -39,10 +39,10 @@ class _2dFigure(_BaseFigure):
ply_object['layout']['scene']['aspectratio'] = dict()
if self.xaxis:
ply_object['layout']['xaxis'] = self.xaxis._to_plotly()
ply_object['layout']['scene']['aspectratio']['x'] = self.xaxis.aspect_ratio
# ply_object['layout']['scene']['aspectratio']['x'] = self.xaxis.aspect_ratio
if self.yaxis:
ply_object['layout']['yaxis'] = self.yaxis._to_plotly()
ply_object['layout']['scene']['aspectratio']['y'] = self.yaxis.aspect_ratio
# ply_object['layout']['scene']['aspectratio']['y'] = self.yaxis.aspect_ratio
return ply_object
......@@ -57,13 +57,13 @@ class _3dFigure(_2dFigure):
ply_object['layout']['scene']['aspectratio'] = dict()
if self.xaxis:
ply_object['layout']['scene']['xaxis'] = self.xaxis._to_plotly()
ply_object['layout']['scene']['aspectratio']['x'] = self.xaxis.aspect_ratio
# ply_object['layout']['scene']['aspectratio']['x'] = self.xaxis.aspect_ratio
if self.yaxis:
ply_object['layout']['scene']['yaxis'] = self.yaxis._to_plotly()
ply_object['layout']['scene']['aspectratio']['y'] = self.yaxis.aspect_ratio
# ply_object['layout']['scene']['aspectratio']['y'] = self.yaxis.aspect_ratio
if self.zaxis:
ply_object['layout']['scene']['zaxis'] = self.zaxis._to_plotly()
ply_object['layout']['scene']['aspectratio']['z'] = self.zaxis.aspect_ratio
# ply_object['layout']['scene']['aspectratio']['z'] = self.zaxis.aspect_ratio
return ply_object
......
from abc import ABCMeta, abstractmethod
class _PlotlyWrapper:
class _PlotlyWrapper(object):
__metaclass__ = ABCMeta
@abstractmethod
......
......@@ -2,5 +2,6 @@ from scatter import *
from heatmap import *
from geomap import *
__all__ = ['Scatter2D', 'Scatter3D', 'ScatterGeoMap', 'HeatMap']
__all__ = ['Scatter2D', 'Scatter3D', 'ScatterGeoMap', 'HeatMap', 'MollweideHeatmap']
from nifty.plotting.plots.private import _PlotBase, _Plot2D
import healpy.projaxes as PA
import healpy.pixelfunc as pixelfunc
class HeatMap(_PlotBase, _Plot2D):
def __init__(self, data, label='', line=None, marker=None, webgl=False, smoothing=False): # smoothing 'best', 'fast', False
def __init__(self, data, label='', line=None, marker=None, webgl=False,
smoothing=False): # smoothing 'best', 'fast', False
_PlotBase.__init__(self, label, line, marker)
self.data = data
self.webgl = webgl
......@@ -17,4 +20,21 @@ class HeatMap(_PlotBase, _Plot2D):
ply_object['type'] = 'heatmap'
if self.smoothing:
ply_object['zsmooth'] = self.smoothing
return ply_object
\ No newline at end of file
return ply_object
class MollweideHeatmap(HeatMap):
def __init__(self, data, label='', line=None, marker=None, webgl=False,
smoothing=False): # smoothing 'best', 'fast', False
HeatMap.__init__(self, _mollview(data), label, line, marker, webgl, smoothing)
def _mollview(x, xsize=800):
import pylab
x = pixelfunc.ma_to_array(x)
f = pylab.figure(None, figsize=(8.5, 5.4))
extent = (0.02, 0.05, 0.96, 0.9)
ax = PA.HpxMollweideAxes(f, extent)
img = ax.projmap(x, nest=False, xsize=xsize)
return img
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment