如何以“ .plotly”扩展名打开文件

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

我下载了在Copernicus website关于气候的交互式工具箱上创建的文件。

我已保存此扩展名:".plotly"

如何打开它-这样我就可以将其作为图片查看?

这是文件的内容:

{"data": [{"mode": "lines+markers", "x": ["2019-01-01", "2019-01-02", "2019-01-03", "2019-01-04", "2019-01-05", "2019-01-06", "2019-01-07", "2019-01-08", "2019-01-09", "2019-01-10", "2019-01-11", "2019-01-12", "2019-01-13", "2019-01-14", "2019-01-15", "2019-01-16", "2019-01-17", "2019-01-18", "2019-01-19", "2019-01-20", "2019-01-21", "2019-01-22", "2019-01-23", "2019-01-24", "2019-01-25", "2019-01-26", "2019-01-27", "2019-01-28", "2019-01-29", "2019-01-30", "2019-01-31"], "y": [1.986506462097168, 1.139273762702942, -0.1418689787387848, -0.714171290397644, -0.4602118134498596, -0.2752906382083893, -0.5288987755775452, -0.7405713796615601, -0.7374019622802734, -0.5999566912651062, -0.5094485878944397, 0.10179024189710617, 1.217246174812317, 1.4535152912139893, 0.9326292872428894, 0.5662962198257446, 0.9379780888557434, 0.3954199254512787, -0.06783988326787949, -0.23851798474788666, -0.8703995943069458, -1.6232084035873413, -0.9794990420341492, -0.9441877007484436, -0.7926209568977356, -0.014816214330494404, -0.14320173859596252, -0.06497668474912643, 0.49699893593788147, 0.4733152687549591, 0.7467145919799805], "type": "scatter", "uid": "ceb1c461-59bb-48e9-bfcc-63396d23a3c9"}], "layout": {"yaxis": {"title": {"text": "Near-Surface Air Temperature anomaly (K)"}}, "xaxis": {"title": {"text": "time"}}}}
python plotly
1个回答
1
投票

您拥有的文件是Plotly JSON chart schema,可以翻译成许多不同的语言,包括python

JSON模式的翻译,可以在多种语言中实际使用也可用

Pythonhttps://plot.ly/python/reference/Rhttps://plot.ly/r/reference/MATLABhttps://plot.ly/matlab/reference/JavaScripthttps://plot.ly/javascript/reference/


直接回答您的问题,您可以如下使用Plotly JSON chart schema上的jsonpython)文件:

import plotly.graph_objects as go
import json

with open("filename.plotly") as f:
    config = json.load(f)

fig = go.Figure(data=config['data'], layout=config['layout'])
fig.show()

enter image description here

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