为什么我的python视觉效果在powerbi服务中比在powerbi桌面中显示得慢?

2024-04-18 13:22:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我在powerbi中制作了一个python可视化。代码如下所示。它在Power BI桌面上运行得相当快,1-2秒就可以弹出视频。但是,当我将它发布到powerbi服务时,显示这个python视觉效果需要10秒。为什么会这样?你知道吗

dates_filtered = dataset.delivery_begin.unique()[-3:]
dataset_plot = dataset[dataset.delivery_begin.isin(dates_filtered)]
fig, ax = matplotlib.pyplot.subplots()
if len(dates_filtered) == 3:
    colors = {
    dates_filtered[0] : "#92bbea" ,
    dates_filtered[1] : "#ea9d9a",
    dates_filtered[2] : "#85ceb3"}
elif len(dates_filtered) == 2: 
    colors = {
    dates_filtered[0] : "#ea9d9a",
    dates_filtered[1] : "#85ceb3"}
else:
    colors = {dates_filtered[0] :  "#85ceb3"}   

grouped = dataset_plot.groupby('delivery_begin')
for key, group in grouped:
    group.plot(ax=ax, kind='line', x = "ep_based_cumsum_bins", y = "adjusted_energy_price", label=key, c= colors[key], legend=False, linewidth = 4)
# grouped.apply(lambda x: x.plot(ax=ax, kind='line', x = "ep_based_cumsum_bins", y = "adjusted_energy_price", label=x.name, c= colors[x.name], legend=False, linewidth = 4))
for item in [fig, ax]:
    item.patch.set_visible(False)
ax.axis('off') 
# ax.legend(dataset_plot.delivery_begin.unique(), loc = 'upper left')
legend = matplotlib.pyplot.legend(fontsize=22, loc = 'upper left', frameon = False)
matplotlib.pyplot.setp(legend.get_texts(), color = 'none')
# ax.legend(loc='upper left', fancybox=True, framealpha=0)
matplotlib.pyplot.show()

Tags: keyfalseplotmatplotlibaxdatasetlocfiltered