Commit 21c7e5d6 authored by Christian Schneider's avatar Christian Schneider
Browse files

Implemented Plot Function

parent 42fb1066
......@@ -7,6 +7,8 @@ from .data_surface import data_surface, data_3d
from .data_IQ import data_IQ
from .functions import *
from .fit_functions import *
from .data_xy import data_xy
from .data_grid import data_grid
# Init bokeh
from bokeh.io import output_notebook
......
......@@ -95,44 +95,33 @@ class data_grid(data_module_base):
self.df = self.df.append({key: value[idx]} for key, value
in zip(order_names, data_arrays))
def plot_hv(self, name_x=None, name_y=None, cmap='magma'):
def plot_hv(self, name_x=None, name_y=None, cmap='magma', height=400,
width=800):
"""Plot table with Holoviews
Parameters
-----------
name_x : None, str, list
Column name(s) used for x axis
name_y : None, str, list
Column name(s) used for y axis
name_x : None, str
Column name used for x axis
name_y : None, str
Column name used for y axis
cmap : str
Name of colormap
height : int
Height of plot in pixels
width : int
Width of plot in pixels
"""
if name_x is None:
x_vals = [self.df.keys()[0]]
elif isinstance(name_x, (list, np.array)):
# len(y) == len(x)
x_vals = []
for x_i in name_x:
x_vals.append(x_i)
x_vals = self.df.dims[0]
else:
x_vals = [name_x]
x_vals = name_x
if name_y is None:
y_vals = [self.df.keys()[1]]
elif isinstance(name_x, (list, np.array)):
# len(y) == len(x)
y_vals = []
for y_i in name_y:
y_vals.append(y_i)
y_vals = self.df.dims[1]
else:
y_vals = [name_y]
if len(y_vals) != len(x_vals):
for i in range(len(y_vals) - len(x_vals)):
x_vals.append(self.df.keys()[0])
y_vals = name_y
hv.opts({'Image': {'plot': {'width': width, 'height': height},
'style': {'cmap': cmap}}})
ds = hv.Dataset(self.df)
hd.regrid(ds.to(hv.Image).opts(
plot=dict(width=800, height=400), Image=dict(cmap=cmap)))
return hd.regrid(ds.to(hv.Image, [x_vals, y_vals]))
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