Interactive graphs in python

579 Views Asked by At

I just had to move from R to Python due to in Python there is a powerful library that I need.

However, these days have been a nightmare with 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.

Now I am handle a new problem. I want to use interactive web base maps using the library Kepler in Python. However, I don't know why I can visualize it in Jupyter and in Spyder not. 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

1

There are 1 best solutions below

0
On

The original kepler.gl library for python is designed only for ipython console within Jupyter by using it's widget functionality. Therefore, you will not able to use directly in Spyder. The immediate solution would be to use an external library in Spyder which allow you to do so. 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. 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.