Closed kcpevey closed 5 years ago
4b. Same goes for the color_range
and colormap
widgets in the Display
tab
geo_opts = dict(width=300, height=300).
.options(**geo_opts)
I was hoping you'd go ahead and comment those notes you had during the meeting last week :) Or were going to write up an example?
Also, this issue https://github.com/pyviz/panel/issues/114 is related as I'm trying to correctly implement panel here. I'm having trouble accessing the visualized widget (I can change it, but when I access it programmatically, it appears unchanged). The way that you modified my solve code makes me think I need Pane in some way, but I'm not sure.
@philippjfr I'm passing this to @JoshuaQChurch . Could you write a quick code snippet on what we discussed in the meeting on Thursday showing the `hv.DynamicMap, the callback function, and how that would fit into this example?
@philippjfr any advice here?
Will get to this first thing tomorrow, am out after a tooth extraction today.
Here's what I've come up with:
from earthsim import parameters
from holoviews.streams import Params
points = gv.operation.project_points(gv.Points((verts.x, verts.y), crs=ccrs.UTM(11)))
# Create a parameterized class to select between ERROR and Depth
results = parameters(display_result=param.ObjectSelector(default=internal_names[0], objects=internal_names))
# Define callback which returns TriMesh for specific time and ERROR/Depth
def time_mesh(time, display_result):
depth_points = points.add_dimension(display_result, 0, dfs[time][display_result].values, vdim=True)
return gv.TriMesh((tris, depth_points), label=label, crs=ccrs.GOOGLE_MERCATOR)
# Declare DynamicMap which varies by time and is linked to results class
meshes = hv.DynamicMap(time_mesh, kdims='Time', streams=[Params(results)]).redim.values(Time=sorted(dfs.keys()))
# Declare classes to control colormap and display range
cmap_opts = parameters(colormap=param.ObjectSelector(default=cc.rainbow, objects={'Rainbow': cc.rainbow}))
display_range = parameters(color_range=param.Range(default=(-0.3, 0.3), bounds=(-0.3, 0.3)))
# Define function which applies colormap and color_range
def apply_opts(obj, colormap, color_range):
return obj.options(cmap=colormap).redim.range(**{obj.vdims[0].name: color_range})
# Apply the colormap and color range dynamically
dynamic = hv.util.Dynamic(rasterize(meshes), operation=apply_opts, streams=[Params(cmap_opts), Params(display_range)])
# Display everything as a Panel
hv_panel = pn.panel(dynamic)
pn.Row(hv_panel[0], pn.Column(hv_panel[1], cmap_opts, display_range, results))
Thank you so much!! I hope you get to feeling better soon!
I confirmed that the colormap picker works for me with this example. I'm fairly certain its a bug in my code that I'm still trying to track down.
I figured out my colormap bug. I'm opening another issue for it.
Great, hope it wasn't too much of a pain to figure out.
This working for me. I'll go ahead and close, but I still think it would make a good addition to the docs :)
I'm trying to take the
Visualizing_Meshes.ipynb
and use panel to add tools to the San Diego error animation cell. My ultimate goal is figure out how to use the param widgets to affect the map.Which looks like this:
Not bad for a first go, but it needs work.
Time
slider?redim.range(HYDRO_ERROR=-0.3, 0.3
to be able to feed it a variable (Philipp has definitely told me this answer before I can't find it.display_result
widget with thelabel
variable such that it will update the map when I change it?