如何在 Spyder IDE 中显示 let-plot 绘图

问题描述 投票:0回答:1

我正在使用spyder ide和Lets-plot来生成绘图。

import numpy as np
import polars as pl
LetsPlot.setup_html()
from lets_plot import *

np.random.seed(12)
data = pl.DataFrame(
    {
    "cond":np.random.lognormal(0, 1, 400),
    "rating":np.concatenate((np.random.normal(0, 1, 200), np.random.normal(1, 1.5, 200)))
    }
)

ggplot(data, aes(x='rating', y='cond')) + \
    geom_point(color='dark_green', alpha=.7) 

它不是显示图形,而是简单地在 ipython 控制台中显示该对象。

<lets_plot.plot.core.PlotSpec at 0x2771422c100>

有什么帮助吗?

python spyder python-polars lets-plot
1个回答
0
投票

尝试做

p=ggplot(data, aes(x='rating', y='cond')) + \
    geom_point(color='dark_green', alpha=.7) 
p.show()

我不使用spyder或letsplot,所以我没有测试过,但我在VSC上的plotly上遇到了类似的问题,我认为这就是让它显示的原因。

© www.soinside.com 2019 - 2024. All rights reserved.