bokeh

bokeh layout vertical alignment with buttons

情到浓时终转凉″ 提交于 2019-12-13 05:07:43
问题 I am looking for a workaround to an issue in Bokeh. When you put a button and a text input in a row- they will be un-alighned. This effect happens because the text input has a label and is described here: https://github.com/bokeh/bokeh/issues/4817 screenshot of messed up alignment Example code: # hello.py from bokeh.io import curdoc from bokeh.layouts import column, row from bokeh.models.widgets import TextInput, Button, Paragraph # create some widgets button = Button(label="Say HI") input =

Jupyter and Bokeh: workaround for exporting bokeh plots when exporting Jupyter notebook to pdf

做~自己de王妃 提交于 2019-12-13 04:08:35
问题 I was hoping some heavy Jupyter and bokeh users might have a workaround for this. So I have a bunch of bokeh plots in my Jupyter notebook and I want to export the notebook to pdf . In the Jupyter Notebook file menu there is an option to download a notebook as a pdf . Also--and my preferred route--is to use nbconvert. The problem is that the bokeh plots are not exported into the final pdf file. Bokeh does not export its plots to a format that is caught by Latex to compile the pdf. In constrast

Using checkbox widget in Bokeh to hide or show lines for dynamic number of lines

核能气质少年 提交于 2019-12-13 03:47:11
问题 I am trying to add checkboxes in my bokeh plot so that I can hide or show different lines in my plot. I found some code from github and modified it to fulfil my purpose. Please have a look into the below code, for data, name, color in zip([AAPL, IBM, MSFT, GOOG], ["AAPL", "IBM", "MSFT", "GOOG"], Spectral4): df = pd.DataFrame(data) source = ColumnDataSource(data = dict(date = pd.to_datetime(df['date']), close = df['close'])) plt = fig.line('date', 'close', line_width=2, color=color, alpha=0.8,

Bokeh multiline plot

試著忘記壹切 提交于 2019-12-13 03:42:23
问题 I am trying to plot RPI, CPI and CPIH on one chart with a HoverTool showing the value of each when you pan over a given area of the chart. I initially tried adding each line separately using line() which kind of worked: However, the HoverTool only works correctly when you scroll over the individual lines. I have tried using multi_line() like: combined_inflation_metrics = 'combined_inflation_metrics.csv' df_combined_inflation_metrics = pd.read_csv(combined_inflation_metrics) combined_source =

Update DataTable on Tap event in Bokeh

余生长醉 提交于 2019-12-13 03:26:55
问题 I am trying to calculate euclidean distance of two points. Initial distance is calculated in the data. Then, when the user is moving the line, I'd like the distance column to update based on the new coordinates. I can see that x and y columns are updating, but not the distance column. Below is my attempt: output_file("tools_point_draw.html") _tools_to_show = 'box_zoom,pan,save,hover,reset,tap' p = figure(x_range=(0, 10), y_range=(0, 10), tools=_tools_to_show, plot_width=862, plot_height=604,

How can I call a JavaScript function from Python using Bokeh?

旧城冷巷雨未停 提交于 2019-12-13 02:53:05
问题 I have this scenario: I have some data (in a pandas dataframe) that I use to draw my plots When I press a button (built by a bokeh widget) I can call my callback method and I do my computation in python. But now I want to send the computed data back to the user in order to show a question in a wizard. So I need to run some JavaScript function. I was thinking of creating a dummy button and run the click method of this button from python. But I think this is not possible. So, how can I run a

Python: Trouble with encoding on Windows (Bokeh plotting library)

风流意气都作罢 提交于 2019-12-13 02:26:53
问题 I am trying to reproduce the simplest examples from the Bokeh tutorial, on a 64-bit Windows machine with Python 3.3.0. Here is the code in its entirety import pandas as pd import numpy as np import matplotlib.pyplot as mpl # NOTE need this import as output_file was not getting imported into the # global namespace import bokeh.plotting as bkp from bokeh.plotting import * # Skip the first point because it can be troublesome theta = np.linspace(0, 8*np.pi, 10000)[1:] # Compute the radial

Write down Bokeh plot selected data not working

若如初见. 提交于 2019-12-13 02:16:32
问题 I am trying to write the selected datapoints from a Bokeh plot. The idea is to access ColumnDataSource selected property to get the selected data points whenever the Button is clicked. Below goes a model of the functionality I'm trying to achieve. Expectation: after clicking the ' Selected points ' button, a file /tmp/datapoints.json would be created containing the list of points selected (if any). Reality: no /tmp/datapoints.json . from bokeh.io import curdoc from bokeh.plotting import

Jinja2 variables in bokeh

对着背影说爱祢 提交于 2019-12-12 22:33:59
问题 I'm trying to pass some variable to a bokeh document which renders a Jinja template. The code is: curdoc().template = template curdoc().template_variables["testvar"] = "cia" curdoc().add_root(row(p1,p2)) If I don't use variables at all in the template and don't try to access them via template_variables all works fine, but with the code above I get the error: curdoc().template_variables["testvar"] = "cia" AttributeError: 'Document' object has no attribute 'template_variables' The command I use

Viewing dicom image with Bokeh

情到浓时终转凉″ 提交于 2019-12-12 17:41:01
问题 I'm trying to set the graph background to a dicom image. I followed this example, but the image data given from dicom.pixel_array isn't RGBA. I'm not sure how to convert it, either. I'm also not sure what exactly bokeh is expecting. I've tried finding specifics in the documentation, but not such luck. from bokeh.plotting import figure, show, output_file import dicom import numpy as np path = "/pathToDicomImage.dcm" data = dicom.read_file(path) img = data.pixel_array p = figure(x_range=(0,10),