bokeh

Is there a way to format the widgets' contents?

╄→гoц情女王★ 提交于 2019-11-29 15:42:55
Let's say I'd like to underline a word in one of my options in a RadioButtonGroup, is it possible? I tried to use the Div class as an input, but it didn't work. Thanks This PR "Add support for specifying CSS classes on all LayoutDOM" will be going into Bokeh 0.12.4 in Dec 2017 and provided a mechanism to add arbitrary CSS classes to any Bokeh LayoutDOM model (e.g. widgets) so that they can be more easily styled. It will be available like: from bokeh.models import Div div = Div(text="some text") # add these CSS classes to the widget div div.css_classes = ["my-custom"] Then you can add styles

How to properly create a HeatMap with Bokeh

旧时模样 提交于 2019-11-29 15:25:37
I'm trying to replicate the HeatMap shown in this question using Bokeh instead of matplotlib. I can't get it quite right though. The existing examples have not helped me to understand what I'm doing wrong. My humble attempt from bokeh.io import output_notebook; output_notebook() from bokeh.charts import HeatMap, show from bokeh.palettes import RdYlGn6 import pandas as pd import numpy as np nba = pd.read_csv(urlopen("http://datasets.flowingdata.com/ppg2008.csv"), index_col=0) # Normalize the data columns and sort. nba = (nba - nba.mean()) / (nba.max() - nba.min()) nba.sort('PTS', inplace=True)

How to change the layout dynamically? How to add and remove layout objects properly?

放肆的年华 提交于 2019-11-29 14:34:55
I need to build an app with many plots. It will have some tabs, and one gridplot within the tabs with some plots. In addition I need to update the plots layout dynamically when the server is running. Remove or add some plots Remove or add some tabs I have read this thread , where Bryan (@bigreddot) says: The most well-used and understood (as well as more efficient) method is to create your plots once, up front, then update only their data when they need to change. Bokeh's layout capability is ambitious and complicated. It works well in a number of situations but I can easily believe there are

Throttling in Bokeh application

夙愿已清 提交于 2019-11-29 09:49:51
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? UPDATE for Bokeh 1.2 As of Bokeh 1.2, the callback policy applies to both JS callbacks as well as Python callbacks on the server. The value

How to add HoverTool to a Data Table (Bokeh, Python)

扶醉桌前 提交于 2019-11-29 09:27:49
问题 I am experimenting with bokeh data table. Is it possible to add HoverTool to each field in bokeh table? An example of DataTable- And and example of how HoverTool works- 回答1: This is possible using HTMLTemplateFormatter : main.py : from os.path import dirname, join import pandas as pd from bokeh.io import curdoc, show from bokeh.models import ColumnDataSource, Div from bokeh.models.widgets import DataTable, TableColumn, HTMLTemplateFormatter from bokeh.layouts import layout template = """<span

With Bokeh, how to save to a png or jpg instead of a html file?

强颜欢笑 提交于 2019-11-29 09:08:11
I need to export pictures of the graphs and plots I am creating with Bokeh. Usually I do output_file("test.html") However, I want to copy that graph into an Excel Sheet. It does not have to be interactive anymore, though that would be brillant. How do I export the graph as a picture? Using code, not clicking on "preview/save". 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" export_svgs(plot, filename="plot.svg") There are

How to add data labels to a bar chart in Bokeh?

余生颓废 提交于 2019-11-29 05:05:24
In the Bokeh guide there are examples of various bar charts that can be created. http://bokeh.pydata.org/en/0.10.0/docs/user_guide/charts.html#id4 This code will create one: from bokeh.charts import Bar, output_file, show from bokeh.sampledata.autompg import autompg as df p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL") output_file("bar.html") show(p) My question is if it's possible to add data labels to each individual bar of the chart? I searched online but could not find a clear answer. Use Labelset Use Labelset to create a label over each individual bar In my example I'm using

multi_line hover in bokeh

这一生的挚爱 提交于 2019-11-29 04:50:50
As in this question: Bokeh multi_line and HoverTool I found that hovertool is not implemented for multi_line plots which is a bit of a setback. This is mentioned under 'warnings' here: http://bokeh.pydata.org/en/0.11.0/docs/reference/models/tools.html#bokeh.models.tools.HoverTool Is there any work arounds for this? Also, If I were to implement this feature, what would be a good place to start and is there anything specific to be aware of? Also, is this feature in the current Bokeh roadmap? As of Bokeh 0.12.4 (earlier, actually but I forget the exact release) the hover tool supports mutli_line

How to interactively display and hide lines in a Bokeh plot?

删除回忆录丶 提交于 2019-11-29 03:18:54
It would be nice to be able to interactively display and hide lines in a bokeh plot. Say, I have created my plot something like this: from bokeh.plotting import output_file, figure, show from numpy.random import normal, uniform meas_data_1 = normal(0, 1, 100) meas_data_2 = uniform(-0.5, 0.5, 100) output_file("myplot.html", title="My plot") fig = figure(width=500, plot_height=500) fig.line(x=range(0, len(meas_data_1)), y=meas_data_1) fig.line(x=range(0, len(meas_data_2)), y=meas_data_2) show(fig) How can I add the possibility to interactively enable/disable one of the two lines? I know that

Streaming two line graphs using bokeh

可紊 提交于 2019-11-29 02:24:42
I would like to create a visualization where there are two line graphs which are updated with one new point per line graph per second. The result will be something like this . I have recently read about bokeh and found out that it can be used in visualizing streams of data in real time. However don't know how to code in it yet. I would appreciate it if someone can show me how this task can be done using bokeh. thanks! Elad Joseph For bokeh-0.11.1 : Basically, you need to run you python app in the bokeh server. Then anyone can connect to the server and view the graph in realtime. First, write