0

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

Orlando G
  • 307
  • 3
  • 11
  • Hi, is the top code (with Kepler) not displaying a plot? Is the bottom code (with plotly) not displaying a plot? When you're running in Spyder, can you run a simple "Hello World" script? Or are you using the immediate window with the >>> ? – rajah9 Sep 13 '20 at 12:01
  • Hello @rajah9 . The first code is a web base map using Mapbox. Yes I can run any other kind of sentences I have been testing pandas and geopandas and all goes good they plot the static maps normally. However, with any interactive graph or map it does not show anything. I runs in the terminal without errors. – Orlando G Sep 13 '20 at 12:16
  • I just upload a image where It is observed that I plot normally a static map and when I run a function from poorly I does not do anything. This does not happen in Jupyter where with the same code I see the figure without problems – Orlando G Sep 13 '20 at 12:21

1 Answers1

2

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.

ikespand
  • 56
  • 1