Commit c40bd411 authored by Christian Schneider's avatar Christian Schneider
Browse files

Added mode flag for plotting

parent 66bba3ab
......@@ -231,7 +231,7 @@ class data_grid(data_module_base):
# Plotting #################################################################
def plot(self, name_x=None, name_y=None, cmap='magma', height=400,
width=800, z_min=None, z_max=None):
width=800, z_min=None, z_max=None, mode='QuadMesh'):
"""Plot table with Holoviews
Parameters
......@@ -251,6 +251,8 @@ class data_grid(data_module_base):
automatically updated to full contrast.
z_max : None, float (Optional)
Maximum value for z values
mode : 'QuadMesh', 'Image'
Choose mode for holoviews plotting
"""
if name_x is None:
x_vals = self.df.dims[0]
......@@ -261,14 +263,17 @@ class data_grid(data_module_base):
y_vals = self.df.dims[1]
else:
y_vals = name_y
hv.opts({'QuadMesh': {'plot': {'width': width, 'height': height},
hv.opts({mode: {'plot': {'width': width, 'height': height},
'style': {'cmap': cmap}}})
# Rename z values (to prevent bug in holoviews)
df = self.df[self.x_min:self.x_max, self.y_min:self.y_max].rename('z')
# Create dataset
ds = hv.Dataset(df)
# Create HoloObject
holo_object = hd.regrid(ds.to(hv.QuadMesh, [x_vals, y_vals]))
if mode == 'QuadMesh':
holo_object = hd.regrid(ds.to(hv.QuadMesh, [x_vals, y_vals]))
else:
holo_object = hd.regrid(ds.to(hv.Image, [x_vals, y_vals]))
# Rescale
holo_object = holo_object.redim.range(**{self.name_v: (z_min, z_max)})
return holo_object
......
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