四边形网格的全息视图和时间滑块不起作用的点
我试图在 hv.quadmesh 或 hv.image 之上覆盖 hv.points,其中这两个图都有时间维度。
import xarray as xr
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh')
#create data
np.random.seed(0)
temperature = 15 + 8 * np.random.randn(2, 2, 3)
precipitation = 10 * np.random.rand(2, 2, 3)
lon = [[-99.83, -99.32], [-99.79, -99.23]]
lat = [[42.25, 42.21], [42.63, 42.59]]
time = pd.date_range("2014-09-06", periods=3)
reference_time = pd.Timestamp("2014-09-05")
ds = xr.Dataset(
data_vars=dict(
temperature=(["x", "y", "time"], temperature),
precipitation=(["x", "y", "time"], precipitation),
),
coords=dict(
lon=(["x", "y"], lon),
lat=(["x", "y"], lat),
time=time,
reference_time=reference_time,
),
attrs=dict(description="Weather related data."),
)
df = ds.temperature.to_dataframe().reset_index()
#create quadmesh plot
img = hv.Dataset(ds, ['lon', 'lat','time'],['temperature']).to(hv.QuadMesh,['lon', 'lat'],['temperature'])
img
#create points plot
pnt = hv.Points(df,vdims=['temperature','time'], kdims=['lon','lat']).groupby('time').opts(color='temperature',cmap='turbo')
pnt
图像和点的总体仅显示第一个图
img*pnt
如果我从点图中删除时间分量,我可以覆盖数据但是那么滑块不会随时间改变点值
img*hv.Points(df,vdims=['temperature','time'], kdims=['lon','lat']).opts(color='temperature',cmap='turbo')
[image*points with no time component][4]
谢谢您的帮助!
I am trying to overaly hv.points on top of hv.quadmesh or hv.image where both these plots have a time dimension.
import xarray as xr
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh')
#create data
np.random.seed(0)
temperature = 15 + 8 * np.random.randn(2, 2, 3)
precipitation = 10 * np.random.rand(2, 2, 3)
lon = [[-99.83, -99.32], [-99.79, -99.23]]
lat = [[42.25, 42.21], [42.63, 42.59]]
time = pd.date_range("2014-09-06", periods=3)
reference_time = pd.Timestamp("2014-09-05")
ds = xr.Dataset(
data_vars=dict(
temperature=(["x", "y", "time"], temperature),
precipitation=(["x", "y", "time"], precipitation),
),
coords=dict(
lon=(["x", "y"], lon),
lat=(["x", "y"], lat),
time=time,
reference_time=reference_time,
),
attrs=dict(description="Weather related data."),
)
df = ds.temperature.to_dataframe().reset_index()
#create quadmesh plot
img = hv.Dataset(ds, ['lon', 'lat','time'],['temperature']).to(hv.QuadMesh,['lon', 'lat'],['temperature'])
img
#create points plot
pnt = hv.Points(df,vdims=['temperature','time'], kdims=['lon','lat']).groupby('time').opts(color='temperature',cmap='turbo')
pnt
Overaly of both image and point only shows first plot
img*pnt
If i remove the time component from the points plot, I can overlay the data but then the slider does not change points value with time
img*hv.Points(df,vdims=['temperature','time'], kdims=['lon','lat']).opts(color='temperature',cmap='turbo')
[image*points with no time component][4]
Thank you for your help !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题可能是由于转换为数据帧时时间对象的转换造成的。
如果您尝试手动选择特定时间步长的数据,
您将遇到错误。
根据我的经验,手动选择时间然后让 HoloViews 决定如何处理对象比分组然后通过
.to()
进行转换效果更好。在您的情况下,这将是以下 3 行:
Your problem is likely due to the transformation of the time objects when you cast to a dataframe.
If you manually try to select data for a particular time step via
you will encounter an error.
In my experience a manual selection of the time and then letting HoloViews decide how to handle the objects works better than grouping and then transforming via
.to()
.In your case this would be the following 3 lines: