简体   繁体   English

python中的交互式图形

[英]Interactive graphs in python

I just had to move from R to Python due to in Python there is a powerful library that I need.我只需要从 R 转移到 Python,因为在 Python 中有一个我需要的强大库。

However, these days have been a nightmare with python.然而,这些天对python来说是一场噩梦。 The topic of the libraries, see the functions, the bunch of IDEs and the visualization is by far much more easier and intuitive in R studio than in Python in my opinion.在我看来,库的主题、查看函数、一堆 IDE 和可视化在 R studio 中比在 Python 中更容易和直观。

Now I am handle a new problem.现在我正在处理一个新问题。 I want to use interactive web base maps using the library Kepler in Python.我想使用 Python 中的 Kepler 库来使用交互式网络底图。 However, I don't know why I can visualize it in Jupyter and in Spyder not.但是,我不知道为什么我可以在 Jupyter 中可视化它,而在 Spyder 中则不能。 Essentially, is the following code:本质上,是以下代码:

import keplergl
from keplergl import KeplerGl
map_1 = KeplerGl()
map_1

and

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(y=[2, 1, 4, 3]))
fig.add_trace(go.Bar(y=[1, 4, 3, 2]))
fig.update_layout(title = 'Hello Figure')
fig.show()

Does any one knows why ?有谁知道为什么? I have the same problem with the library plotly我对图书馆有同样的问题

Thank you.谢谢你。

Example例子

The original kepler.gl library for python is designed only for ipython console within Jupyter by using it's widget functionality. python 的原始 kepler.gl 库仅通过使用它的小部件功能而设计用于 Jupyter 中的 ipython 控制台。 Therefore, you will not able to use directly in Spyder.因此,您将无法直接在 Spyder 中使用。 The immediate solution would be to use an external library in Spyder which allow you to do so.直接的解决方案是在 Spyder 中使用一个允许您这样做的外部库。 For instance, check keplergl-cli 0.3.1 which has a functionality to visualize the full kepler map in a browser with a similar code.例如,检查keplergl-cli 0.3.1 ,它具有在浏览器中使用类似代码可视化完整开普勒地图的功能。 Following is directly copied from their documentation:以下是直接从他们的文档中复制的:

from keplergl_cli import Visualize
vis = Visualize(api_key=MAPBOX_API_KEY)
vis.add_data(data=data, names='name of layer')
vis.add_data(data=data2, names='name of layer')
html_path = vis.render(open_browser=True, read_only=False)

You can also use a slightly modified version of this library from here and this will also give you functionality to save this kepler map to desired location and option to turn off rendering.您还可以从此处使用此库的稍微修改版本,这还将为您提供将此开普勒地图保存到所需位置的功能以及关闭渲染的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM