我保存了这个扩展名: ".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"}}}}
您拥有的文件是Plotly JSON图表架构,可以转换为许多不同的语言,包括python:
还可以使用几种语言对JSON模式进行实际使用的翻译:
Python
:https
R
: //plot.ly/python/reference/
MATLAB
:https
JavaScript
: //plot.ly/r/reference/:https : //plot.ly/matlab/reference/:https : //plot.ly/javascript/参考/
直接回答您的问题,您可以按以下方式使用Plotly JSON图表架构(json
)文件python
:
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()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句