bokeh

Smooth curved line between 3 points in plot

扶醉桌前 提交于 2019-12-06 14:12:49
问题 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

Bokeh nested column layout

送分小仙女□ 提交于 2019-12-06 11:53:16
问题 I want to create a nested layout in bokeh with 2 columns. The left column has 2 plots, one above the other. The right column has a number of widgets, all stacked ontop of each other. I also want everything to autofit within the browser window: I currently have something like this: from bokeh.io import curdoc from bokeh.layouts import row, column, widgetbox, layout from bokeh.models import ColumnDataSource from bokeh.models.widgets import Slider, TextInput, Button, CheckboxGroup,

Plotting Bar Charts with Bokeh

主宰稳场 提交于 2019-12-06 10:48:36
I am trying to plot a basic barchart but I keep seeing an error called 'StopIteration'. I am following an example, and the code seems fine: amount = bugrlary_dict.values() months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] print len(amount) print len(months) bar = Bar(amount, months, filename="bar.html") bar.title("Bar Chart of the Amount of Burglaries").xlabel("Months").ylabel("Amount") bar.show() Leb UPDATE this answer is out of date and will not work with Bokeh versions newer than 0.10 Please refer to recent documentation You're passing invalid input. From

Jupyter Bokeh: Non-existent column name in glyph renderer

爷,独闯天下 提交于 2019-12-06 10:28:02
问题 I have a GlyphRenderer whose data_source.data is {'index': [0, 1, 2, 3, 4, 5, 6, 7], 'color': ['#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f']} The renderer's glyph is Oval(height=0.1, width=0.2, fill_color="color") When rendering, I see E-1001 (BAD_COLUMN_NAME): Glyph refers to nonexistent column name: color [renderer: GlyphRenderer(id='1d1031f5-6ee3-4744-a0f7-22309798e313', ...)] I'm clearly missing something, but this is pretty much lifted from

Bokeh Plot with a nominal or ordinal axis type

♀尐吖头ヾ 提交于 2019-12-06 10:16:13
Edit: The code in the original question refers to a version of Bokeh that is years out of date. But the answer below has been updated to answer the same question for modern versions of Bokeh Bokeh Plot with a nominal axis type from bokeh.plotting import * from bokeh.objects import * output_notebook() label = ['United States', 'Russia', 'South Africa', 'Europe (average)', 'Canada', 'Austalia', 'Japan'] number = [1, 2, 3, 4, 5, 6, 7] value = [700, 530, 400, 150, 125, 125, 75] yr = Range1d(start=0, end=800) figure(y_range=yr) rect(number, [x/2 for x in value] , width=0.5, height=value, color = "

categorical y-axis and datetime x-axis with Bokeh vbar plot

左心房为你撑大大i 提交于 2019-12-06 09:48:40
I want to draw a vbar plot using bokeh, where x-axis takes datetime and y-axis takes categorical values. Initially I tried circle plot as follows: import pandas as pd from datetime import datetime from dateutil.parser import parse from bokeh.plotting import figure, show, output_notebook from bokeh.models.ranges import FactorRange x = pd.Series(['2017/1/1', '2017/1/2', '2017/1/3', '2017/1/4']).map(lambda x: parse(x)) y = ["a", "b", "c", "a"] p = figure(x_axis_type='datetime', y_range=list(set(y)), plot_width=400, plot_height=200) p.circle(x, y, size=10, line_color="blue", line_width=1) show(p)

Example: how do I make bokeh omit missing dates when using datetime as x-axis

烈酒焚心 提交于 2019-12-06 09:45:35
I was looking for a way to eliminate the "spaces" in the x-axis where there is no data, this for a bokeh graph. Then I stumbled on an example here: How do I make bokeh omit missing dates when using datetime as x-axis The example: from math import pi import pandas as pd from bokeh.sampledata.stocks import MSFT from bokeh.plotting import figure, show, output_file from bokeh.models.formatters import TickFormatter, String, List # In this custom TickFormatter, xaxis labels are taken from an array of date # Strings (e.g. ['Sep 01', 'Sep 02', ...]) passed to the date_labels property. class

How to animate a circle using bokeh

假如想象 提交于 2019-12-06 09:44:09
Note from maintainers: This question concerns the obsolete first generation Bokeh server. For details about modern Bokeh server applications, see: https://docs.bokeh.org/en/latest/docs/user_guide/server.html OBSOLETE: I am currently working on this simple project using bokeh plotting through a server, attempting to move a circle in a circle. The two examples that I have been trying to learn from are https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/animated.py and https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/line_animate.py As their documentation is

Can I update a bokeh plot without callbacks from the server?

被刻印的时光 ゝ 提交于 2019-12-06 09:17:23
I want Bokeh to update periodically and arbitrarily when the results from a separate algorithm running in python returns results, not based on any input from the Bokeh interface. I've tried various solutions but they all depend on a callback to a some UI event or a periodic callback as in the code below. import numpy as np from bokeh.plotting import figure, curdoc from bokeh.models import ColumnDataSource, Plot, LinearAxis, Grid from bokeh.models.glyphs import MultiLine from time import sleep from random import randint def getData(): # simulate data acquisition # run slow algorith sleep

Bokeh: CustomJS Callback for Mouse Move or Click

会有一股神秘感。 提交于 2019-12-06 08:42:49
问题 I want to update my plot data based on the current mouse position. What I'm aiming for is something like the interactive power function plot, but instead of taking the exponent from a slider, take the exponent to be the current x-value of the mouse cursor (in plot coordinate space, not display coordinates). If it's not possible to get an onMouseMove callback, onClick would also be ok. However, I don't want to have to click a specific graph (then I could use TapTool), but tapping anywhere in