In this article, we’ll compare Bokeh and Dash (by Plotly), two Python alternatives for the Shiny framework for R, using the same example.
Bokeh: BSD 3-Clause (permissive license). It depends on Jinja2 (BSD), MarkupSafe (BSD), PyYAML (MIT), numpy (BSD), python-dateutil (simplified BSD), and Tornado (Apache). All these licenses are permissive as well.
Dash: MIT (permissive license). It depends on Flask (BSD), MarkupSafe (BSD), chardet (LGPL), decorator (new BSD license), jsonschema (MIT), plotly (MIT), pytz (MIT), requests (Apache 2.0), traitlets (BSD), urllib3 (MIT). All these licenses are permissive as well.
Bokeh: supported natively with interactions
Dash: not supported, but Plotly is
Dash: Yes for the core framework. You can also write custom React components or find some on the internet.
You can play with the frameworks yourself:
These examples show how a selection component can update the graphs. They also show how selecting data on a graph updated the other components. It is clear on those recordings that Dash is less slowed down by big datasets than Bokeh. Both dashboards also look very similar.
Another point is interaction consistency. See what happens in the Bokeh example when you first select a category on top, then select data on the scatter plot and then unselect a category. Data in the Bokeh graphs becomes inconsistent. If you come up with an elegant solution to this issue, please let me know. On the contrary, Dash will maintain a common state and I’ve never seen inconsistencies arise.
I gave up on Bokeh a long time ago and have been very happy with plotly and dash. At the time Bokeh was just too hard to use and the documentation wasn’t very good. Plotly has always been incredibly intuitive.
I personally have been using bokeh and have liked it so far. I recall toying with plotly for some small thing that didn’t work at the time due to a known bug but haven’t had the time to revisit it.
I’ve been using Dash for a few months and find it great to quickly get something up and running. Incredibly easy to get live updates and great visualisation. Bokeh was just frustrating when I tried it.
Having used both (started with Bokeh, then moved to Dash), I am finding Dash to be far easier to learn and get working, as well as easier to maintain.
Right now I think that the may detriment to Dash is a lack of some features/capabilities, but it is under pretty active development and new capabilities are coming down the pipe quickly.
Before looking at the code comparison between Bokeh and Dash, you should look at this paragraph.
The dataset we’ll base our implementation examples on is a list of Kickstarter projects. I parsed, cleaned and assembled this dataset in a single CSV file that you can find here. How I did it is beyond this article’s scope but feel free to ask me.
You will find the examples for Bokeh and Dash in the GitHub repository dashboards-frameworks-comparison. For each dashboard framework, you will find the library dependencies in a file
requirements.txt. To install them use
pip install -r requirements.txt .
The dataset will be loaded in the following way throughout the examples:
We’ll also need some global variables for formatting (Note: usage of global variables in a production environment is not advised. It makes the code simpler here).
When giving lines of code for each example, those previous lines will be excluded.
Lines of code for the example: 139
Version of Bokeh in the example: 0.12.13
Development difficulty felt: 4/5. I found it hard to use the Bokeh data sources because I wanted (and failed) to link them to my pandas dataframes. Configuring graphs to look like I wanted was a hassle, and it took me a lot of time to get around how interactions work.
You can find the whole example in the dashboard-frameworks-comparison repository.
bokeh serve app.py
Lines of code for the example: 105
Version of Dash in the example: 0.18.3
Development difficulty felt: 2/5. The only difficulty I had was how to use the
dcc.Graph object with the regular plotly library. When that was clear for me, development was a breeze.
dcc.Graphdoes not contain the two attributes
dataand layout. Those attributes are defined in the callbacks functions below.
Find more about interactions in Dash here.
Run the dashboard with
This article was supposed to be a comparison of multiple dashboard frameworks for python. I previously included Pyxley, and Pydashie. However, these projects have either been abandoned or lack proper documentation.
I also had unsuccessfully tested the Bowtie library. The Bowtie author saw this article and made an effort to improve the documentation and include an example based on the Kickstarter Dashboard. I suggest you check it out.
I would use Dash by default:
it uses plotly for python which makes it very powerful
it uses React on the frontend which makes it easy add components
I coded more easily on Dash than on Bokeh, which confirms the opinion of other users I cited
If you’re still unsure about which one to choose:
Do a POC on Dash of your most critical features
Do a POC on Bokeh if you got blocked by a lack of interactions between graphs (like panning multiple graphs at the same time)
Then decide if you want to sacrifice some features to use Dash or if you’re fine with Bokeh
How to Perform Fraud Detection with Personalized Page Rank
This article shows how to perform fraud detection with Graph Analysis.
Set up TensorFlow with Docker + GPU in Minutes
Why Docker is the best platform to use Tensorflow with a GPU.
Introducing tf-explain, Interpretability for TensorFlow 2.0
A Tensorflow 2.0 library for deep learning model interpretability.