我目前正在尝试在matplotlib后端使用holoviews+datashader。我使用的数据具有非常不同的x和y范围,结果是datashader图被拉伸得毫无帮助。我尝试使用的opts和output关键字可以解决holoviews只绘制图的问题,但一旦应用datashade就不行了。在
例如:
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
产生: datashader and points output
我可以使用fig_size opts关键字控制点的大小
^{pr2}$但同样的方法不适用于datashader图。任何关于用matplotlib改变这种数据阴影图形大小的建议都将不胜感激。理想情况下,我希望使用函数而不是cellmmagic关键字,这样代码就可以移植到脚本中。在
谢谢!在
在HoloViews中更改matplotlib绘图的大小总是由外部容器控制的,因此当您有一个布局时,您可以更改该对象的大小,例如,在您的示例中:
另一个可能令人困惑的地方是,RGB元素(datashade操作返回的内容)默认使用aspect='equal'。您可以通过将纵横比设置为“正方形”或显式纵横比来更改该值:
^{pr2}$把这些放在一起,你可能想做这样的事情:
相关问题 更多 >
编程相关推荐