7 ms·
Bokeh – a Python interactive visualization library
- jbritton 11y ago"Bokeh is a Python interactive visualization library that targets modern web browsers for presentation." A description of how one gets from Python to a web browser display would be nice. Is there a translation from Python to Javascript somewhere? Is there a Python web server backend? Are there dynamic visual updates or does this thing just generate a static output like a .png file?
- mfisher87 11y agoFrom the docs, under "Getting started": > When you execute this script, you will see that a new output file "lines.html" is created, and that a browser automatically opens a new tab to display it. (For presentation purposes we have included the plot output directly inline in this document.) This is based on an example calling an output_file() function, but the docs also mention output_notebook(), and I'm sure you can output to HTML as a string as well. I didn't spend too much time digging yet.
- canavandl 11y agoYes - there's the ability to generate the raw html of a plot or a JS script and div that can be embedded in an HTML doc. Source: http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html
- cmdrfred 11y agomy question exactly. What does this do that I can't do with highcharts?
- infinite8s 11y agoThe idea behind bokeh is that you don't need to know JavaScript and can use an api that's familiar to a lot of people coming from matplotlib
- birdsarah 11y agoi would say bokeh is more similar to d3 than highcharts (although my under-standing of highcharts may be off) 1) you can create any viz you want to - you have access to very low-level elements and can build up anything from them 2) it's liberally open source licensed why i initially got sucked into bokeh over d3 is that: a) I prefer python b) I find it more intuitive (d3 always messes with my head)
- birdsarah 11y agoI forgot the really important difference between bokeh and highcharts - you can throw 100k points at it and have it be fully interactive without your browser blowing up!
- mianos 11y agoHiCharts has dynamically loadable data. I have a database that has 120M points. I just keep some pre aggregated data to populate the wide periods. As you zoom it it selects smaller aggregation sets. (Think; 1 month for 10 years, 2 weeks for 1 year, etc). If you have the data you only need about 20 lines of JS so support this with json. That said, bokeh requires little to no javascript and that's a huge advantage if you need to get multiple visualizations. It does, pretty much stock, what you can do with HiCharts without needing as much full-stack expertise.
- pwang 11y agoIn the Dev Guide docs, there is a section about why we built our own Javascript charting library from the ground up: http://bokeh.pydata.org/en/latest/docs/dev_guide/bokehjs.html#bokehjs-motivations http://bokeh.pydata.org/en/latest/docs/dev_guide/bokehjs.htm...
- ced 11y ago> A description of how one gets from Python to a web browser display would be nice. Check out Jupyter notebooks. > Is there a Python web server backend? That's possible for dynamic charts, but for most usage, Bokeh saves all the chart's data inside the .html file (yielding sometimes huge files). See http://bokeh.pydata.org/en/latest/docs/gallery.html http://bokeh.pydata.org/en/latest/docs/gallery.html for examples.
- birdsarah 11y ago> A description of how one gets from Python to a web browser display would be nice http://birdsarah.github.io/europython-2015-bokeh/static/slides.html#/4 http://birdsarah.github.io/europython-2015-bokeh/static/slid... python (or r or scala) spits out json that is consumed by bokehjs
- pwang 11y agoThere is a full-featured javascript runtime "BokehJS" which is designed from the ground up to be driven by remote (aka server-side) models, which are sent over the wire as JSON. The server-side models are generated programmatically via Python, R, Scala, etc. The cool thing is that a lot of the interactivity is completely native in BokehJS, so you can build interactive Javascript visualizations from Python, and have an entirely static HTML document that embeds a lot of rich interactivity. See, for instance, Sarah Bird's excellent GapMinder example: http://nbviewer.jupyter.org/github/bokeh/bokeh-notebooks/blob/master/tutorial/00%20-%20intro.ipynb#Interaction http://nbviewer.jupyter.org/github/bokeh/bokeh-notebooks/blo... When you move the slider, it generates JS events which drive model updates completely in the browser, which then update the objects that comprise the plot. All of that is built straight from Python, but there is no Python kernel running in the background. Bokeh also lets you write your event handlers in Python, and reside on the server, and get called back automatically when the user interacts with the plot in some way. Check out this app for example: http://demo.bokehplots.com/apps/selection_histogram http://demo.bokehplots.com/apps/selection_histogram You can use the lasso tool to select some points, and that computes a new sub-histogram. Here is the entirety of the code for it: https://github.com/bokeh/bokeh/blob/master/examples/app/selection_histogram.py https://github.com/bokeh/bokeh/blob/master/examples/app/sele... For more deep-dive on the architecture, you can start at this slide and walk through: http://www.slideshare.net/misterwang/bokeh-tutorial-pydata-strata-san-jose-2015/18 http://www.slideshare.net/misterwang/bokeh-tutorial-pydata-s... Or you can watch this webinar recording (start at the 19 minute mark): https://continuum-analytics.wistia.com/medias/f6wp9dam91 https://continuum-analytics.wistia.com/medias/f6wp9dam91
- asafira 11y agoAre the visualizations downloaded at page load only, or can they be readily fashioned with websockets, etc to turn them into an interactive dashboard? I've been considering running out lab experiments off of a webapp, but haven't found an easy enough solution.
- canavandl 11y agoApart from rendering static html plots or plots with client-side JS callbacks, you could look into using the new bokeh server: http://bokeh.pydata.org/en/latest/docs/user_guide/server.html http://bokeh.pydata.org/en/latest/docs/user_guide/server.htm... It allows for building streaming visualizations or plots with using websockets (implemented using tornado).
- eruditely 11y agoI've been playing around with this library and really like it. Python really is that much easier to use than R isn't it? Too bad most on the libraries are still in R. It's strange that there isn't a language written on top of R that is less troublesome to use or learn.
- Lofkin 11y agoCall the libraries with Rpy2, or build models using a DAG of functions and distributions with pymc 3
- eruditely 11y agoThanks i'll check that out.
- falaki 11y agoFortran programmers find it much "easier" than other languages. You are arguing about a subjective matter here. The fact that there are so many R packages and users shows it is useful to a large enough subset of users in statistics/data science domain.
- hodwik 11y agoSpeakers of English think it is easier than Swahili, but we know from language acquisition studies that Swahili is easier to learn in the large. Your use of "subjective" is imprecise and overly relativistic. Just because something has to do with the human mind, or human experience, doesn't make that thing a priori subjective.
- travisoliphant 11y agoThere are a lot of smart people that like Python. There are a lot of smart people that like R too. Bokeh is designed to be useful from both R and Python (and other languages as well). Here is a recent presentation showing Bokeh (from Python) along with data-shading to visualize billions of points quickly: http://www.slideshare.net/continuumio/visualizing-billions-of-data-points-doing-it-right http://www.slideshare.net/continuumio/visualizing-billions-o... Here is another presentation showing integration of Bokeh with R to visualize geographical data from another group: http://ryanhafen.com/blog/rbokeh-gmap http://ryanhafen.com/blog/rbokeh-gmap 0.11 and above releases of Bokeh contain a server that provides a very nice application model that can be synchronized between browser and server for allowing data scientists to build interactive plotting-based applications in the browser. Here are some simple examples of that: http://demo.bokehplots.com/ http://demo.bokehplots.com/
- codelion 11y agoGreat library, specially useful for doing streaming visualizations. I gave a talk last year at PyData Singapore about it, slides are available here - http://asankhaya.github.io/professional.html#PyDataSG http://asankhaya.github.io/professional.html#PyDataSG
- canavandl 11y agoThat's super cool.
- herrkanin 11y agoSince I have never really liked Matplotlib I would really like to learn Bokeh, but unfortunately its inability to export its visualizations in SVG or similar formats makes it kind of useless for me as a scientist wanting to publish my results.
- pen2l 11y agoThey're working on it, probably in a month or two you'll be able to do it: https://groups.google.com/a/continuum.io/forum/#!searchin/bokeh/svg/bokeh/biqOu8T23l0/L2yxwHSx3nQJ https://groups.google.com/a/continuum.io/forum/#!searchin/bo... At the current time you can export to png, or maybe export to svg in a roundabout manner, by turning html page into pdf, turning pdf into svg, etc.
- ISL 11y agoA png isn't a vector format, so the important property of the SVG (or EPS, PDF) is lost. A vectorized bitmap is still a bitmap.
- pwang 11y agoWhat resolution are you looking for in print? If you export your raster at 300 dpi, and enable lossless PNG compression, shouldn't it suffice for most print purposes?
- andrepd 11y agoIt still has limited resolution and a much higher storage footprint. Plotting charts is the vector graphics use case par excellence. Having svg support is a no brainer.
- pwang 11y agoOf course you're right that we do need to support SVG and vector formats, but it's also not entirely true that "vector >> raster" in all cases. Raster does have limited resolution, but so does your screen or most output devices (yes, even scientific plotters). It's also not necessarily true that it has a higher storage footprint; it depends on the complexity and number of glyphs, the fonts you need to embed for the LaTeX formulae, etc. etc. In large-data cases, raster can be a much more viable visualization transfer medium.
- blt 11y agoStrange name, it refers to the way a camera lens blurs out-of-focus objects (especially highlights) into a disc shape [1]. I was expecting an image processing library. Bokeh is widely discussed by photography equipment aficionados as one of the main distinguishing traits of different lens designs besides sharpness, distortion, etc. edit: maybe it is an allusion to bubble plots? [1] https://www.google.com/search?q=bokeh&tbm=isch https://www.google.com/search?q=bokeh&tbm=isch
- birdsarah 11y agoi believe the idea behind the name is that bokeh (python) is to data viz what bokeh is to photography - its a tool that brings the important data into focus.....
- dmoy 11y agobokeh by definition is talking about the out of focus stuff, which is arguably the less important part of a shot.
- andrepd 11y agoWhich brings in focus elements into sharper attention.
- skeletonjelly 11y agoAnd a photo that is entirely bokeh? http://i.imgur.com/siLB9C3.jpg http://i.imgur.com/siLB9C3.jpg
- pwang 11y agoIn the "Technical Vision" part of our docs, I speak to this a little bit: http://bokehplots.com/pages/technical-vision.html http://bokehplots.com/pages/technical-vision.html A very large part of the vision is that we want to support accurate and useful visualization on large datasets. This is now encapsulated in the Datashader library (although it plays well with Bokeh itself): https://github.com/bokeh/datashader https://github.com/bokeh/datashader If you are interested in this, we just did a webinar this week on Datashader, and demonstrate how to easily visualize billions of points through the browser, in a few seconds, on a single machine: https://continuum-analytics.wistia.com/medias/8zu9idwoym?mkt_tok=3RkMMJWWfF9wsRonvajNZKXonjHpfsX57ukuWaazlMI%2F0ER3fOvrPUfGjI4AT8ZnI%2BSLDwEYGJlv6SgFSbjCMbhuzbgLUxk%3D https://continuum-analytics.wistia.com/medias/8zu9idwoym?mkt...
- bootload 11y ago"To use the Bokeh server with python 2.7, you also need to install Futures package." Does this statement mean it supports Py3 and if you want to use it with 2.7 you need Futures? Or is it only Py2.X? [0] [0] http://bokeh.pydata.org/en/latest/docs/installation.html http://bokeh.pydata.org/en/latest/docs/installation.html
- travisoliphant 11y agoBokeh can be used with both Python 2.7 and Python 3. Additional dependencies are needed to work with Python 2.7. In fact, the "write call-back functions in Python" capability uses a Python to JS compiler called Flexx -- http://flexx.readthedocs.org/en/latest/flexjs http://flexx.readthedocs.org/en/latest/flexjs. Flexx is currently Python 3 only (though 2.7 support is coming for it).
- bootload 11y agothx @travisoliphant the requirements are not clear in the docs. This explanation makes more sense.
- fpliger 11y agoThanks for the feedback. We keep a continuous and frequent effort to make documentation more efficient and straightforward .. Building clear is a constant/endless effort and feedback is very important. To clarify, Futures is required for bokeh server as an extra dependency on Python 2.7 since it's not a battery included like for Python > 3.2.. if you conda install Bokeh it should be installed already for you. You can find more info about the bokeh server features here: http://bokeh.pydata.org/en/latest/docs/user_guide/server.html http://bokeh.pydata.org/en/latest/docs/user_guide/server.htm... and here: http://bokeh.pydata.org/en/latest/docs/user_guide/cli.html#module-bokeh.command.subcommands.serve http://bokeh.pydata.org/en/latest/docs/user_guide/cli.html#m... Flexx, on other hand, is not required by bokeh server itself but instead to define python functions to handle interactivity that runs on the browser (no need of bokeh server). Flexx is used to convert python to JS. You can find more info here: http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#customjs-with-a-python-function http://bokeh.pydata.org/en/latest/docs/user_guide/interactio...
- MrBra 11y agoRuby is so behind in this... :/ The closest thing I could find, which is only just a proposed enhancement in a github project, is considering adding ploty.js to Flammarion (a new Ruby GUI toolkit using the browser as working window), or maybe Ruby Processing to some extent?
- pwang 11y agoActually, we'd LOVE to get a bokeh.rb project going! Most of the power of Bokeh is in the BokehJS runtime, and in our M-VM-V-C architecture for visualization. The Python code is just generating a JSON representation of the plot, but it's relatively straightforward to do that from any language. You can see front-end implementations in other languages: * R: https://github.com/bokeh/rbokeh https://github.com/bokeh/rbokeh * Scala: https://github.com/bokeh/bokeh-scala https://github.com/bokeh/bokeh-scala * Julia: https://github.com/bokeh/Bokeh.jl https://github.com/bokeh/Bokeh.jl The Facebook data science folks even implemented a small Bokeh wrapper in Lua, as part of their iTorch package: https://github.com/facebook/iTorch/blob/master/Plot.lua https://github.com/facebook/iTorch/blob/master/Plot.lua So, you can see that you can get started with a basic wrapper, and then build up from there. The Lua wrapper is only ~850 lines. If you want to pop over to the mailing list or on our Github, we'd love to help you out.
- Niksko 11y agoBokeh is cool, but I've found that it's method for customizing appearance of graphs is a little unintuitive and clunky. For example, have a look at this cursory analysis of my Reddit comments that I did late last year. Getting the graphs to look nice felt like pulling teeth at the time. http://nbviewer.jupyter.org/github/Niksko/redditCommentData/blob/master/CommentAnalysis.ipynb http://nbviewer.jupyter.org/github/Niksko/redditCommentData/... That being said, I'm reasonably happy with the results. And that pannable, zoomable line graph is pretty fancy and is easy to set up.
- navbaker 11y agoAny chance of getting access to the old tutorials that consisted of scripts with the boilerplate written, but missing the key functionality? I was really enjoying working through them and digging into the docs, then all of a sudden they were taken offline and I was directed to the notebooks.