我正在尝试创建一个包含多个类别的图,并为每个类别创建一个图。
由于有这么多的数据点,我正在使用数据阴影。但是 datashade 忽略了我为这些图设置的宽度和高度。
使用数据着色器时,如何保持我已经为绘图设置的宽度和高度?
下面是示例代码:
# import libraries
import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
import holoviews as hv
hv.extension('bokeh')
from holoviews.operation.datashader import datashade
# create some sample data
sample_scatter1 = np.random.normal(loc=0.0, size=50)
sample_scatter2 = np.random.normal(loc=300., size=50)
sample_category = np.random.choice(2, size=50)
demo_df = pd.DataFrame({
'col1': sample_scatter1,
'col2': sample_scatter2,
'category': sample_category,
})
hv_demo_df = hv.Dataset(demo_df, kdims=['col1', 'category'], vdims=['col2'])
# when i plot without datashade, width works fine
# but with using datashade here i lose the width that i set
datashade(hv_demo_df.to.scatter().opts(width=1000).layout('category')).cols(1)