[英]Altair library | Difficulty to save a Chart in .png
I'm trying to save an Altair Chart in .png howether I get the error below.我正在尝试以 .png 格式保存 Altair 图表,但出现以下错误。 Could you please help me, I don't know what I'm doing wrong.
你能帮我吗,我不知道我做错了什么。
For information I manage to save the graph in .html and .json format, but nether .png, .jpeg, .svg aren't working.有关信息,我设法将图形保存为 .html 和 .json 格式,但下界 .png、.jpeg、.svg 不起作用。 I already tried to insall
altair_saver
that returns me Requirement already satisfied
.我已经尝试安装
altair_saver
,它返回给我Requirement already satisfied
altair_saver
。
Thank you for your help.感谢您的帮助。
>>> plot.save('src/modality.png')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/app/installer/envPySpark/lib/python3.6/site-packages/altair/vegalite/v4/api.py", line 476, in save
result = save(**kwds)
File "/app/installer/envPySpark/lib/python3.6/site-packages/altair/utils/save.py", line 121, in save
**kwargs,
File "/app/installer/envPySpark/lib/python3.6/site-packages/altair/utils/mimebundle.py", line 60, in spec_to_mimebundle
return altair_saver.render(spec, format, mode=mode, **kwargs)
File "/app/installer/envPySpark/lib/python3.6/site-packages/altair_saver/_core.py", line 255, in render
Saver = _select_saver(method, mode=mode, fmt=fmt)
File "/app/installer/envPySpark/lib/python3.6/site-packages/altair_saver/_core.py", line 69, in _select_saver
raise ValueError(f"No enabled saver found that supports format={fmt!r}")
ValueError: No enabled saver found that supports format='png'
After running this command line with my conda env使用我的 conda env 运行此命令行后
$ conda install -c conda-forge altair_saver
A new error appear :出现新错误:
>>> plot.save('src/modality.png')
TypeError: Cannot read property 'getContext' of null
at resize (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-scenegraph/build/vega-scenegraph.js:3377:26)
at CanvasRenderer.prototype$6.resize (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-scenegraph/build/vega-scenegraph.js:3427:5)
at CanvasRenderer.prototype$4.initialize (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-scenegraph/build/vega-scenegraph.js:2989:17)
at CanvasRenderer.prototype$6.initialize (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-scenegraph/build/vega-scenegraph.js:3422:28)
at initializeRenderer (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-view/build/vega-view.js:630:8)
at renderHeadless (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-view/build/vega-view.js:736:12)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async View.renderToCanvas [as toCanvas] (/export/home/cgilles/.user_conda/miniconda/envs/metrologie/lib/vega-cli/node_modules/vega-view/build/vega-view.js:771:15)
In order to save a chart as PNG, you need to install altair_saver
, as well as the additional dependencies required for either the nodejs or selenium backend.为了将图表保存为 PNG,您需要安装
altair_saver
以及 nodejs 或 selenium 后端所需的其他依赖项。 Details are available here: https://github.com/altair-viz/altair_saver#installation详情请见: https : //github.com/altair-viz/altair_saver#installation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.