9/1/2023 0 Comments Bokeh python interactive plotKeep in mind that you can customize Bokeh plots till the cows come home. ipynb file and open within your own IPython Notebook session. If you want to reproduce it, download the. Note that the nbviewer won’t show the plot as it can only display content embedded into the. You can find an IPython Notebook with the code used to create the above plot here. The plot axes automatically scale and pan themselves to reflect changes imposed by these tools. As you can see Bokeh automatically provides tools to pan and zoom the view and even save and resize the plot itself. Upon execution, the output of this last cell should be something like what is shown in the figure below. Lastly, we’ll use the very simple line() function of the otting module to create the plot and the show() function to… well show it: (x,y, line_width=3.0) Enter the code below in a subsequent cell: import numpy Here we will calculate the values, coordinates if you will, of a simple sine wave using NumPy. Having Bokeh in place we’re ready to do some plotting. Should the above code go through without a hitch the output of the cell should read Configuring embedded BokehJS mode. The ‘Session Management’ section of the Bokeh Reference Guide has more info on the available output options. The first command obviously imports the otting module while the second sets the output of any subsequent plotting to be directly ‘fed’ to your IPython Notebook as the output of a typical cell. That should launch a browser with IPython Notebook where you should just create a new notebook.Īll you need to do to import and enable Bokeh for plotting within your notebook is to enter the following code within one of the cells: import otting Merely start your IPython Notebook by entering ipython notebook in your terminal (after having activated the environment in which Bokeh is installed). I’m not going to go into detail here over the inner-workings of Bokeh but rather give quick instructions on how to ‘enable’ it into your IPython Notebook and create a simple plot show-casing some of the interactivity offered by the package. Note that if you have multiple separate Python environments, e.g., a Python 2.7 and a Python 3.4 environment as was shown in this previous post, you will need to activate the environment you would like to use Bokeh in and use the above command in order to ‘link’ that package (upon installation into the root environment). InstallationĪs with most things, a good place to start is the ‘Quick-start’ page.Īssuming you’re running an Anaconda distro, the best way to install bokeh is simply by opening a terminal and entering: conda install bokeh While Bokeh doesn’t have as many bells and whistles as Plotly (see next post), its entirely free and unrestricted and works like a charm within the IPython console and the IPython Notebook. Bokeh can help anyone who would like to quickly and easily create interactive plots, dashboards, and data applications. Its goal is to provide elegant, concise construction of novel graphics in the style of D3.js, but also deliver this capability with high-performance interactivity over very large or streaming datasets. If I may quote:īokeh is a Python interactive visualization library that targets modern web browsers for presentation. A static version of such a plot, which I shamelessly screen-captured from the Plotly website can be seen in the figure below.īokeh is a package by Continuum Analytics, authors of the Anaconda distribution of which I spoke in this previous post. Packages such as Bokeh and Plotly (see below) save you a lot of that trouble by providing an easily embeddable plot directly into your beloved IPython Notebook along with a series of ‘tools’ allowing you to zoom and pan the plot, resize the whole thing, save as a static image, or even hover over the plotted data and get lil’ tooltips with their underlying data. Well, with interactive plotting the days of the static plot are dwindling. One would have to change axes limits, margins, line-widths, etc etc. I will also provide some very rudimentary examples that should allow to get started straight away.Īnyone who’s delved into ‘exploratory’ data analysis requiring a depiction of their results would have inevitably come to the point where they would need to fiddle with plotting settings just to make the result legible (much more work required to make it attractive). This post will focus on Bokeh while the next post will be about Plotly. In this post I will talk about interactive plotting packages that support the IPython Notebook and allow you to zoom, pan, resize, or even hover and get values off your plots directly from an IPython Notebook. Interactive Plotting in IPython Notebook (Part 1/2): Bokeh Summary
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |