Initializing the app itself is basically the same as Flask. The sightings do have some odd times in there, so in a later post I’ll go back and add a conditional to that comprehension. from csv import DictReader fin = open ( 'data/bfro_report_locations.csv', 'r' ) reader = DictReader ( fin ) BFRO_LOCATION_DATA = fin. The semantics are cleaner, and performance really isn’t an issue - most of the time will be spent on the client rendering all of the plots, not filtering a 3000 element list. This could be done with a pandas data frame, but I actually like the model of a list of dictionaries a bit better for this application. We’ve got the data, so it needs to be loaded into the app. I’ll get the data, which is a geocoded list of Bigfoot Field Researchers Organization (BFRO) verified Bigfoot sightings, from data.world and put it in data/bfro_report_locations.csv. Generally the best idea is to do this in a Python or Anaconda virtual environment. We’re going to need some prerequisites installed. I’ll probably spend some time going over the plot semantics because the docs for Dash and Plotly aren’t particularly consistent in that regard, but if it’s obvious I’m not going to explain it.
The purpose of this series of posts is to walk through a real app example rather than introduce the Dash framework itself, which the official docs already do a great job of. I’m going to assume you’re familiar with the HTML and core components, specifically the graphs.
It’s highly recommended that you read the awesome Dash user guide before going through this. The second part will be to add the additional plots with a more complex layout, and the third part will be adding the title filter bar and the associated interactions. I’ve broken this into three parts: the first part will load the data, make a map, and initialize the server. The magic will be in the search bar, which will filter the titles of the sightings based on the text you put into it. Here’s what the final thing will look like:īasically it’ll be four plots - a map of the geolocated sightings, a line/scatter plot of sightings over time, a bar plot of sightings by day of week, and a donut chart ( totally not a bar chart) of the percentage of sightings for each sighting class. Here’s what I want to build: an application that shows various highly critical and important visualizations and statistics about sasquatch sightings, with the added ability to filter the sightings based on words I think might help me narrow down the search to relevant areas. It’s a framework in the vein of R’s Shiny, with the key advantage being that it isn’t R.Ĭonsidering my recent efforts to make one million dollars by finding Bigfoot had stalled, I figured it was as good a time as any to take this framework for a spin and try to make bank.
Not too long ago, Plotly announced a new open source framework for Python-based web applications called Dash ( announcement letter).
Building a map of Bigfoot sightings with Plotly’s Dash framwork.