bokeh

Limit bokeh plot pan to defined range

北城以北 提交于 2019-12-05 01:15:53
问题 I was wondering if it were possible to limit the range of the "pan" tool for bokeh generated plots? For example, say I had this simple plot: from bokeh.plotting import output_file, rect, show output_file('test.html') rect([10,20,30], [10,20,30], width=[1,2,3], color=['red','blue','green'], height=5, plot_width=400, plot_height=400, tools = "ypan,box_zoom,reset") show() The ypan tool works great, but I could keep panning until my graph disappears. Is there any way I can constrain the pan? 回答1:

How to stop bokeh from opening a new tab in Jupyter Notebook?

大城市里の小女人 提交于 2019-12-05 00:46:53
First of all, before this is tagged as duplicate, I have read the other solutions and unfortunately none of them worked for me. My problem is that I want to display a bokeh plot in Juypter Notebook (and only in Jupyter Notebook), not in a new tab/window. In the official documentation here I am told that I only need to change output_file to output_notebook Even though the plot is now displayed inline if I do that, bokeh won't stop also opening a new tab and needlessly displaying the plot there. Since I'm gonna create lots of plots in my project, it'd be very nice to not always have to close

is there a way to save bokeh data table content

穿精又带淫゛_ 提交于 2019-12-04 21:43:42
问题 I am experimenting with bokeh data table to display data embedded in web page. It works quite nicely. Is there a way to save the table content from the displayed data table? Other bokeh plots have tool bar for various functions including saving, but the DataTable does not seem to come with it. I know very little about javascript or slickgrid, which bokeh data table uses. And wondering if it can be done. Thanks! EDIT - It appears the my original question was not clear enough. Hope following

How to fit bokeh plot size dynamically

大城市里の小女人 提交于 2019-12-04 21:03:32
My questions is very similar to the one asked yesterday: Bokeh resize plot dynamically But since I feel a solution may be a little bit different between the two, I would like to post my own. also I copy the entire code so that anyone can just copy/paste and run it. In the below code, I basically want the second Bokeh plot to take up the entire view port when I click on the title and return to the original size on the next click. As a side information, I borrowed part of the code from github. Bootstrap4 is used for css. TweenMax for animation and of course the plotting library is Bokeh. The

Bokeh: How to change extra axis visibility

半世苍凉 提交于 2019-12-04 20:51:19
I know I can turn axes on and off in bokeh with p1.xaxis.visible = None or p1.yaxis.visible = None from Hide Axis in Bokeh . What if I have an extra y range I want to change the visibility of? I've defined my extra axis like this: plot.extra_y_ranges = {'ORP': Range1d(start=0, end=plot_d['y_axis2_max'])} plot.add_layout(LinearAxis(y_range_name='ORP', axis_label='ORP, mV'), 'left') I tried plot.extra_y_ranges.visible = None but it has no effect, and I wasn't able to find anything in the documentation. Have I missed something? You need to change the visibility of the lines, not the axis. I've

Filtering dataframe using Bokeh/Widget/Callback

会有一股神秘感。 提交于 2019-12-04 19:17:00
Currently my data set is in the format: Date, Currency, Price which I am filtering at Currency level and then using it to generate graphs. I want to improve it so that all the filtering is done using Python widget/Dropdown boxes? I'm new to Python/Bokeh so I need some help. Date Currency Price 1/1/2017 AUDUSD 1.01 2/1/2017 AUDUSD 1.02 3/1/2017 AUDUSD 1.03 1/1/2017 USDJPY 1.01 2/1/2017 USDJPY 1.02 3/1/2017 USDJPY 1.03 1/1/2017 CADUSD 1.01 2/1/2017 CADUSD 1.02 3/1/2017 CADUSD 1.03 #Creating CCyPair wise menu menu = Select(options=['AUDUSD','USDJPY'], value='AUDUSD') #Function for dataframe def

38个常用Python库:数值计算、可视化、机器学习等8大领域都有了

旧巷老猫 提交于 2019-12-04 18:46:32
作者:李明江 张良均 周东平 张尚佳 来源:华章科技 01 数值计算 数值计算是数据挖掘、机器学习的基础。Python提供多种强大的扩展库用于数值计算,常用的数值计算库如下所示。 1. NumPy 支持多维数组与矩阵运算,也针对数组运算提供大量的数学函数库。通常与SciPy和Matplotlib一起使用,支持比Python更多种类的数值类型,其中定义的最重要的对象是称为ndarray的n维数组类型,用于描述相同类型的元素集合,可以使用基于0的索引访问集合中元素。 2. SciPy 在NumPy库的基础上增加了众多的数学、科学及工程计算中常用的库函数,如线性代数、常微分方程数值求解、信号处理、图像处理、稀疏矩阵等,可进行插值处理、信号滤波,以及使用C语言加速计算。 3. Pandas 基于NumPy的一种工具,为解决数据分析任务而生。纳入大量库和一些标准的数据模型,提供高效地操作大型数据集所需的工具及大量的能快速便捷处理数据的函数和方法,为时间序列分析提供很好的支持,提供多种数据结构,如Series、Time-Series、DataFrame和Panel。 02 数据可视化 数据可视化是展示数据、理解数据的有效手段,常用的Python数据可视化库如下所示。 4. Matplotlib 第一个Python可视化库,有许多别的程序库都是建立在其基础上或者直接调用该库

Smooth curved line between 3 points in plot

感情迁移 提交于 2019-12-04 18:24:53
I have 3 data points on the x axis and 3 on the y axis: x = [1,3,5] y=[0,5,0] I would like a curved line that starts at (1,0), goes to the highest point at (3,5) and then finishes at (5,0) I think I need to use interpolation, but unsure how. If I use spline from scipy like this: import bokeh.plotting as bk from scipy.interpolate import spline p = bk.figure() xvals=np.linspace(1, 5, 10) y_smooth = spline(x,y,xvals) p.line(xvals, y_smooth) bk.show(p) I get the highest point before (3,5) and it looks unbalanced: The issue is due to that spline with no extra argument is of order 3. That means that

Bokeh: ValueError: Out of range float values are not JSON compliant

我的梦境 提交于 2019-12-04 18:23:59
问题 I came across this discussion (from a year ago): https://github.com/bokeh/bokeh/issues/2392 I also saw the white screen without any errors..and then i tried to take a small subset of 2 columns and tried the below: Since pandas just gets a bunch of rows with empty data in there as well, I tried dropna.. this resulted in there being no data at all. So instead I just specified the rows that should go into the df (hence the df = df.head(n=19) line) import pandas as pd from bokeh.plotting import

How do I adjust number format in bokeh data table using HTMLTemplateFormatter?

試著忘記壹切 提交于 2019-12-04 18:13:17
How do I adjust the number format of data in HTMLTamplateFormatter. I would like the number format to be "(0,0)". Here is sample code with the incorrect attempt: from bokeh.models import ColumnDataSource from bokeh.models.widgets import DataTable, TableColumn, HTMLTemplateFormatter, NumberFormatter from bokeh.io import show dict1 = {'x':[0]*6,'y':[500,1000,-1000,1000,-5000,500],'z':[0,0,1,1,1,2]} source = ColumnDataSource(data=dict1) template=""" <b><div style="background:<%= (function colorfromint(){ if(z == 1){ return("NavajoWhite")} else{if(z == 2){ return("Orange")} else{return("")} }}())