jupyter notebook 中使用Pyecharts后render_notebook()方法不能绘图解决方案

问题描述:在jupyter notebook 中安装Pyecharts最新版1.9.1之后,发现使用render_notebook()方法,图形无法正常显示。
解决方案:
1,安装pyecharts-assets
通过Gitcode安装pyecharts-assets
按照说明,启动cmd命令行,依次输入下列指令,将库克隆到本地。

# 通过 git clone
git clone https://github.com/pyecharts/pyecharts-assets.git
# 进入克隆文件夹
cd pyecharts-assets
# 安装插件
jupyter nbextension install assets
# 激活插件
jupyter nbextension enable assets/main

2,安装jupyter-echarts-pypkg
在Gitcode上安装jupyter-echarts-pypkg
按照说明,启动cmd命令行,依次输入下列指令,将库克隆到本地。

# 通过 git clone
git clone https://github.com/pyecharts/jupyter-echarts-pypkg.git
# 进入克隆文件夹
cd jupyter-echarts-pypkg
# 安装插件
python setup.py install

3,安装jupyter-echarts
在Gitcode上安装jupyter-echarts
按照说明,启动cmd命令行,依次输入下列指令,将库克隆到本地。

# 通过 git clone
git clone https://gitcode.com/pyecharts/jupyter-echarts.git
# 进入克隆文件夹
cd jupyter-echarts
# 安装插件
jupyter nbextension install echarts
# 激活插件
jupyter nbextension enable echarts/main

完成后重启Jupyter notebook,图形可以正常显示

在PyCharm使用Jupyter Notebook时遇到Pyecharts图表显示空白的情况,可能是由于多种原因造成的。以下是一些可能的解决方案: 1. 确保你已经安装了pyecharts库以及其依赖项jupyterthemes和notebook。如果没有安装,可以使用pip命令进行安装: ``` pip install pyecharts jupyterthemes notebook ``` 2. 如果你安装了pyecharts,确保安装了最新版本的pyecharts,有时候老版本的库可能存在bug,可以通过以下命令更新: ``` pip install --upgrade pyecharts ``` 3. 检查Jupyter Notebook的主题设置。有时候某些主题可能会导致图表显示不正常。你可以在Jupyter Notebook运行以下代码来更改主题: ```python from jupyterthemes import jtplot jtplot.style(theme='grade3') ``` 4. 如果以上方法都无效,尝试在Jupyter Notebook添加以下代码,以确保图表能够被正确渲染: ```python from pyecharts import options as opts from pyecharts.charts import Bar # 你的绘图代码 bar = Bar() bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) bar.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) bar.render_notebook() ``` 5. 确保你的Jupyter Notebook和浏览器是最新版本。如果浏览器缓存或者兼容性问题,也可能导致图表显示不出来。 如果以上方法不能解决问题,可以尝试查看Pyecharts官方文档或者社区寻求帮助。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清弦墨客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值