Bubble Plot

The bubble plot function returns a Plotly scatter plot layered ontop of a map. The color of the markers will indicate the number of detections at each location. Alternatively, you can indicate the number of individuals seen at each location by using type = 'individual'.

Warning

Input files must include station , catalognumber, unqdetecid, latitude, longitude, and datecollected as columns.

from resonate.bubble_plot import bubble_plot
import pandas as pd
import plotly.offline as py

df = pd.read_csv('/path/to/detections.csv')

To display the plot in iPython use:

bubble_plot(df)

Or use the standard plotting function to save as HTML:

bubble_plot(df,ipython_display=False, filename='/path_to_plot.html')

You can also do your count by number of individuals by using type = 'individual:

bubble_plot(df, type='individual')

Mapbox

Alternatively you can use a Mapbox access token plot your map. Mapbox is much for responsive than standard Scattergeo plot.

Example Code

mapbox_access_token = 'ADD_YOUR_TOKEN_HERE'
bubble_plot(df, mapbox_token=mapbox_access_token)

Below is the sample output for blue sharks off of the coast of Nova Scotia.


Bubble Plot Function

bubble_plot.bubble_plot(detections, type='detections', ipython_display=True, title='Bubble Plot', height=700, width=1000, plotly_geo=None, filename=None, mapbox_token=None, marker_size=10, colorscale='Viridis')

Creates a plotly abacus plot from a pandas dataframe

Parameters:
  • detections – detection dataframe
  • ipython_display – a boolean to show in a notebook
  • title – the title of the plot
  • height – the height of the plotl
  • width – the width of the plotly
  • plotly_geo – an optional dictionary to controle the geographix aspects of the plot
  • filename – Plotly filename to write to
  • mapbox_token – A string of mapbox access token
  • marker_size – An int to indicate the diameter in pixels
  • colorscale – A string to indicate the color index
Returns:

A plotly geoscatter plot or mapbox plot