0

我目前正在尝试将 holoviews+datashader 与 matplotlib 后端一起使用。我使用的数据有非常不同的 x 和 y 范围,结果是数据着色器图被无用地拉伸。我尝试使用的 opts 和 output 关键字可以解决仅使用全息视图的问题,但一旦应用数据阴影就无法解决。

例如:

import holoviews as hv
hv.extension('matplotlib')
import numpy as np
from holoviews.operation.datashader import datashade

np.random.seed(1)
positions = np.random.multivariate_normal((0,0),[[0.1,0.1], [0.1,50.0]], (1000000,))
positions2 = np.random.multivariate_normal((0,0),[[0.1,0.1], [0.1,50]], (1000,))
points = hv.Points(positions,label="Points")
points2 = hv.Points(positions2,label="Points2")
plot = datashade(points) + points2
plot

生成: 数据着色器和点输出

我可以使用 fig_size opts 关键字来控制点的大小

e.g. points2(plot=dict(fig_size=200))

但同样不适用于数据着色器图。任何有关使用 matplotlib 更改此类数据着色器图形大小的建议将不胜感激。理想情况下,我想使用函数而不是单元格魔术关键字,以便可以将代码移植到脚本中。

谢谢!

4

1 回答 1

0

在 HoloViews 中更改 matplotlib 绘图的大小始终由外部容器控制,因此当您拥有 Layout 时,您可以更改该对象的大小,例如在您的示例中为:

plot = datashade(points) + points2
plot.opts(plot=dict(fig_size=200))

可能令人困惑的另一部分是 RGB 元素(这是 datashade 操作返回的内容)默认使用 aspect='equal'。您可以通过将 aspect 设置为“square”或显式宽高比来更改它:

datashade(points).opts(plot=dict(fig_size=200, aspect='square'))

把它们放在一起,你可能想做这样的事情:

plot = datashade(points).opts(plot=dict(aspect='square')) + points2
plot.opts(plot=dict(fig_size=200))
于 2018-02-04T17:19:52.180 回答