bokeh

Throttling in Bokeh application

淺唱寂寞╮ 提交于 2019-11-30 08:18:59
问题 I have Bokeh application with a Slider widget that uses the Slider.on_change callback to update my graphs. However, the slider updates come in much faster than my callback function can handle so I need a way to throttle the incoming change requests. The problem is very prominent since the slider calls into the callback during sliding, while only the last slider value (when the user releases the mouse) is of interest. How could I tackle this problem? 回答1: UPDATE for Bokeh 1.2 As of Bokeh 1.2,

How to color rows and/or cells in a Bokeh DataTable?

自古美人都是妖i 提交于 2019-11-30 07:43:58
Starting from Initial table , I need to highlight(color) elements as shown in either one of the table examples Ex. 1, Ex. 2, Ex. 3 . Any idea? In case someone else might bump into the same need, here are some variants that I came up with. (Thanks to Bokeh team for hints!) Variant 1: Highlight the cell where column A > column B Code: from bokeh.io import output_notebook, show output_notebook() from random import randint from bokeh.io import output_file, show from bokeh.layouts import widgetbox from bokeh.models import ColumnDataSource from bokeh.models.widgets import DataTable, DateFormatter,

Position the legend outside the plot area with Bokeh

半腔热情 提交于 2019-11-30 07:39:09
I am making a plot following the example found here Unfortunately, I have 17 curves I need to display, and the legend overlaps them. I know I can create a legend object that can be displayed outside the plot area like here , but I have 17 curves so using a loop is much more convenient. Do you know how to combine both methods? Ok, I found the solution. See the code below where I have just modified the interactive legend example: import pandas as pd from bokeh.palettes import Spectral4 from bokeh.plotting import figure, output_file, show from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG

How to add a Callback to Bokeh DataTable?

拟墨画扇 提交于 2019-11-30 03:51:23
I am trying to use Bokeh to make an editable DataTable that updates the source data when the data is edited. I started with the standard DataTable example here , and make the editable kwarg to true. Here is where I am at: from datetime import date from random import randint from bokeh.models import ColumnDataSource, Callback from bokeh.models.widgets import DataTable, DateFormatter, TableColumn from bokeh.io import output_file, output_notebook, show, vform output_notebook() data = dict(dates=[date(2014, 3, i+1) for i in range(10)], downloads=[randint(0, 100) for i in range(10)]) source =

How to do waffle charts in python? (square piechart)

独自空忆成欢 提交于 2019-11-30 03:40:15
Something like this: There is a very good package to do it in R . In python, the best that I could figure out is this, using the squarify package (inspired by a post on how to do treemaps ): import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns # just to have better line color and width import squarify # for those using jupyter notebooks %matplotlib inline df = pd.DataFrame({ 'v1': np.ones(100), 'v2': np.random.randint(1, 4, 100)}) df.sort_values(by='v2', inplace=True) # color scale cmap = mpl.cm.Accent mini, maxi = df['v2'].min()

Embedding a bokeh app in flask

寵の児 提交于 2019-11-30 03:14:55
I am trying desperately to embed a working bokeh applet into flask, and can't find a proper way to do this. I looked through all the examples, but I can't find one which includes the ability to update the data (best example: the sliders_applet). If I'm not mistaken, I do need the bokeh-server to be able to change the data (with sliders etc.). Starting the applet this way works, e.g.: bokeh-server --script sliders_app.py But I can't find the proper, or at least a working way to embed the sliders_app into flask. And since it should be possible to use multiple applets, it doesn't seem clean to me

How to rotate X-axis labels in bokeh figure?

爱⌒轻易说出口 提交于 2019-11-30 00:42:13
问题 I'm just starting to use Bokeh. Below I create some args I use for the rect figure. x_length = var_results.index * 5.5 Multiplying the index by 5.5 gave me more room between labels. names = var_results.Feature.tolist() y_length = var_results.Variance y_center = var_results.Variance/2 var_results is a Pandas dataframe that has a typical, sequential, non-repeating index. var_results also has a column Features that is strings of non-repeated, names, and finally it has a column Variance which is

Python Flask App with Interactive Bokeh plots

别说谁变了你拦得住时间么 提交于 2019-11-29 22:38:38
问题 I have a Flask App in which my plots are created using Bokeh in the controller python code with below commands: p = figure(tools = TOOLS, x_axis_label ...) p.line(....) script, div = components(p) and I pass "script" & "div" elements to my HTML page using: render_template(.html, script = script, div =div) I want to add a interactive slider bar on top of my plot. Based on the Bokeh website with the following command, I should be able to do it. slider = Slider(start=0, end=10, value=1, step=.1,

Exporting figures from Bokeh as svg or pdf?

假如想象 提交于 2019-11-29 16:49:32
问题 Is it possible to output individual figures from Bokeh as pdf or svg images? I feel like I'm missing something obvious, but I've checked the online help pages and gone through the bokeh.objects api and haven't found anything... 回答1: There is no way to save PDF currently, but as of Bokeh 0.12.6 , it is now possible to export PNG and SVG directly from Python code. Exporting PNGs looks like this export_png(plot, filename="plot.png") And exporting SVGs looks like this plot.output_backend = "svg"

When plotting with Bokeh, how do you automatically cycle through a color pallette?

寵の児 提交于 2019-11-29 16:39:30
问题 I want to use a loop to load and/or modify data and plot the result within the loop using Bokeh (I am familiar with Matplotlib's axes.color_cycle). Here is a simple example import numpy as np from bokeh.plotting import figure, output_file, show output_file('bokeh_cycle_colors.html') p = figure(width=400, height=400) x = np.linspace(0, 10) for m in xrange(10): y = m * x p.line(x, y, legend='m = {}'.format(m)) p.legend.location='top_left' show(p) which generates this plot How do I make it so