Commit e5672410 authored by Mihai Baltac's avatar Mihai Baltac

+ colorscale + axes fix

parent 82a92a51
Pipeline #24028 failed with stages
in 4 minutes and 37 seconds
......@@ -7,10 +7,15 @@ from nifty.plotting.plots import Heatmap, HPMollweide, GLMollweide
class Figure2D(FigureFromPlot):
def __init__(self, plots, title=None, width=None, height=None,
xaxis=None, yaxis=None):
"""
:param title: title of figure (subtitle when used as subfigure)
:param xaxis: Nifty Axis, if folse, then not displayed (false default for Mollweide)
:param yaxis: Nifty Axis, if folse, then not displayed (false default for Mollweide)
"""
if plots is not None:
if isinstance(plots[0], Heatmap) and width is None and \
height is None:
height is None:
(x, y) = plots[0].data.shape
if x > y:
......@@ -21,7 +26,7 @@ class Figure2D(FigureFromPlot):
width = int(500 * y / x)
if isinstance(plots[0], GLMollweide) or \
isinstance(plots[0], HPMollweide):
isinstance(plots[0], HPMollweide):
xaxis = False if (xaxis is None) else xaxis
yaxis = False if (yaxis is None) else yaxis
......@@ -49,19 +54,23 @@ class Figure2D(FigureFromPlot):
plotly_object['layout']['scene']['aspectratio'] = {}
if self.xaxis:
plotly_object['layout']['xaxis'] = self.xaxis.to_plotly()
elif not self.xaxis:
elif self.xaxis is False:
plotly_object['layout']['xaxis'] = dict(
autorange=True,
showgrid=False,
zeroline=False,
showline=False,
autotick=True,
ticks='',
showticklabels=False
)
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False
)
if self.yaxis:
plotly_object['layout']['yaxis'] = self.yaxis.to_plotly()
elif not self.yaxis:
plotly_object['layout']['yaxis'] = dict(showline=False)
elif self.yaxis is False:
plotly_object['layout']['yaxis'] = dict(
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False
)
return plotly_object
......@@ -27,16 +27,34 @@ class Figure3D(FigureFromPlot):
if self.xaxis:
plotly_object['layout']['scene']['xaxis'] = self.xaxis.to_plotly()
elif not self.xaxis:
plotly_object['layout']['scene']['xaxis'] = dict(showline=False)
plotly_object['layout']['scene']['xaxis'] = dict(
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False
)
if self.yaxis:
plotly_object['layout']['scene']['yaxis'] = self.yaxis.to_plotly()
elif not self.yaxis:
plotly_object['layout']['scene']['yaxis'] = dict(showline=False)
plotly_object['layout']['scene']['yaxis'] = dict(
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False
)
if self.zaxis:
plotly_object['layout']['scene']['zaxis'] = self.zaxis.to_plotly()
elif not self.zaxis:
plotly_object['layout']['scene']['zaxis'] = dict(showline=False)
plotly_object['layout']['scene']['zaxis'] = dict(
showgrid=False,
zeroline=False,
showline=False,
ticks='',
showticklabels=False
)
return plotly_object
......@@ -7,7 +7,12 @@ from nifty.plotting.plotly_wrapper import PlotlyWrapper
class Heatmap(PlotlyWrapper):
def __init__(self, data, color_map=None, webgl=False, smoothing=False):
# smoothing 'best', 'fast', False
"""
:param data: 2D array to plot
:param color_map: Nifty Colormap, None as default
:param webgl: optimized for webgl
:param smoothing: 'best', 'fast', False
"""
if color_map is not None:
if not isinstance(color_map, Colormap):
......@@ -19,6 +24,7 @@ class Heatmap(PlotlyWrapper):
self.data = data
def at(self, data):
if isinstance(data, list):
temp_data = np.zeros((data[0].shape))
for arr in data:
......@@ -39,7 +45,6 @@ class Heatmap(PlotlyWrapper):
plotly_object['z'] = self.data
plotly_object['showscale'] = False
if self.color_map:
plotly_object['colorscale'] = self.color_map.to_plotly()
plotly_object['colorbar'] = dict(title=self.color_map.name, x=0.42)
......
Markdown is supported
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