from tkinter import *
import plotly.graph_objects as go
root = Tk()
root.geometry("1300x700")
mapbox_access_token ="pk.eyJ1Ijoidml2ZWtrdW1hcmxhbCIsImEiOiJjazdoZDI2enkwOTBiM21sbGpubnQwN3g4In0.ClK-bWxExBsMOcHoyvcrXg"
fig = go.Figure(go.Scattermapbox(
lat=['45.5017'],
lon=['-73.5673'],
mode='markers',
marker=go.scattermapbox.Marker(
size=14
),
text=['Montreal'],
))
fig.update_layout(
hovermode='closest',
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=go.layout.mapbox.Center(
lat=45,
lon=-73
),
pitch=0,
zoom=5
)
)
fig.place(width=600, x=0, y=25)
fig.show()
mainloop()
I tried to display mapbox in tkinter but getting errors.
AttributeError Traceback (most recent call last)
<ipython-input-16-3312bf82150d> in <module>
28 )
29 )
---> 30 fig.place(width=600, x=0, y=25)
31 fig.show()
32 mainloop()
AttributeError: 'Figure' object has no attribute 'place'
The code without tkinter is running perfect on jupyter notebook. but want to know how to display it in tkinter.
figobject has noplace()method, this is not a tkinter widget. According to stackoverflow.com/questions/38426263/…, I don't think it is possible to embed a plotly graph in a tkinter window (while it is possiblle in a jupyter notebook).