Bokeh vs Dash — Which is the Best Dashboard Framework for Python?
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 and Dash: an overview
- Official website for Bokeh / Gallery of examples for Bokeh
- Official website for Dash / Gallery of examples for Dash
- 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.
Jupyter and Zeppelin notebooks?
- Bokeh: supported natively with interactions
- Dash: not supported, but Plotly is
Requires only Python knowledge?
- Dash: Yes for the core framework. You can also write custom React components or find some on the internet.
Comparing the frameworks visually
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.
User testimonials (from Reddit)
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.
A quick word about the implementation examples
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 .
Contribute to dashboards-frameworks-comparison development by creating an account on GitHub.github.com
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.
Bokeh implementation example
- 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.
Imports and setup
Start the Bokeh dashboard
bokeh serve app.py
Dash implementation example
- 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.Graphobject with the regular plotly library. When that was clear for me, development was a breeze.
Imports and setup
Find more about interactions in Dash here.
Start the Dash dashboard
Run the dashboard with
Alternatives to Bokeh and Dash
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
Want more articles like this one? Don’t forget to click the Follow button!