不显示折线怎么办
时间: 2023-08-06 20:07:50 浏览: 137
如果你绘制的折线图没有显示出来,可能是因为你没有在 Jupyter Notebook 中启用 Pyecharts 的渲染器。
你可以使用以下代码来启用 Pyecharts 的渲染器:
``` python
from pyecharts.globals import CurrentConfig, NotebookType
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_NOTEBOOK
```
然后,重新运行绘制折线图的代码,看看能否正常显示折线图。如果还是无法正常显示,你可以尝试使用以下代码来显示图表:
``` python
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot as driver
from pyecharts import options as opts
from pyecharts.charts import Line
line_chart = Line()
line_chart.add_xaxis(data['x']) # x 轴数据
line_chart.add_yaxis('y1', data['y1']) # y1 轴数据
line_chart.add_yaxis('y2', data['y2']) # y2 轴数据
line_chart.set_global_opts(title_opts=opts.TitleOpts(title="折线图")) # 设置图表标题
make_snapshot(driver, line_chart.render(), "折线图.png")
```
这样,你就可以在 Jupyter Notebook 中显示折线图了。请确保你已经安装了 `snapshot-selenium` 库。
相关推荐
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)