I have a scattermapbox plot that plots a scatterplot of 1,000’s of points based on a dataframe from a text file over a map based on lat/lon.
I would like the hover text at minimum to show the date/time of each point, would love lat/lon and date/time but I can only seem to get one or the other.
I have 5 text files within the directory, each based on a whole year of data. I created a for loop to run through each file and plot one .html file per year/file. Each plot features two different separated datasets, a drop down menu to show all points and the separated data, and annotations.
I did try to create one plot featured on concatenated dataframe of all years and separate by year in the drop down menu, but the dataframe appears to be too large and causes me numerous issues when trying to separate (only plotting 3 years or so of data and causing the drop down menu to not work properly).
Anyways, the program that plots each year separately with the for loop plots everything properly except the hover text, only showing the lat/lon and then the type or name of that data. I have another, earlier edition of the program that only plot one file, no for loop and it plots properly, including the hover text showing the date/time. In troubleshooting, I have copied the code, and ran each but I keep running into issues.
# Use Scattermap box for satellite maps data = [ go.Scattermapbox( lat= df_c2c['lat'], lon= df_c2c['lon'], text = [str(n) for n in df['datetime']], hoverinfo = 'text', mode='markers', marker = dict(color='yellow', size=5), name = 'Cloud to cloud', legendgroup = 'Cloud to cloud' ), go.Scattermapbox( lat= df_c2g['lat'], lon= df_c2g['lon'], text = [str(n) for n in df['datetime']], hoverinfo = 'text', mode='markers', marker = dict(color='red', size=5), name = 'Cloud to ground', legendgroup = 'Cloud to ground' ) ] # Declare Layout layout = go.Layout( title = 'LTG '+str(year_plt)+'', font=dict(family='Courier New, monospace', size=18, color='rgb(0,0,0)'), autosize=False, hovermode='closest', showlegend=True, width=1800, height=1000, mapbox=dict( accesstoken=mapbox_access_token, #width=1415, bearing=0, center=dict( lat=41.717, lon=-87.733 ), pitch=0, zoom=8, style='satellite-streets' ), )
In the above plotting code, with no text and hoverinfo, it’ll show just the lat/lon. With the text and hoverinfo, it will show the date/time, except when run in the for loop that runs all the files one at a time.
Any help with the solution? Or even just plotting solutions to general issues I had?