bokeh

How do I work with images in Bokeh (Python)

我的未来我决定 提交于 2019-11-27 09:13:40
For example you can plot an image in matplotlib using this code: %matplotlib inline import matplotlib.pyplot as plt import matplotlib.image as mpimg img=mpimg.imread('image.png') plt.imshow(img) Is something like this possible with Bokeh(0.10)? You can use the ImageURL glyph ( image_url plot method)to load images locally or from the web. from bokeh.plotting import figure, show, output_file output_file('image.html') p = figure(x_range=(0,1), y_range=(0,1)) p.image_url(url=['tree.png'], x=0, y=1) show(p) One gotcha - if you graph only an image (and no other data), you'll have to explicitly set

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

这一生的挚爱 提交于 2019-11-27 08:10:48
问题 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

Flask + Bokeh AjaxDataSource

核能气质少年 提交于 2019-11-27 05:57:05
问题 Struggling with Flask + Bokeh AjaxDataSource: I have a function that returns json data: @app.route("/data", methods=['POST']) def get_x(): global x, y x = x + 0.1 y = math.sin(x) return flask.jsonify(x=[x], y=[y]) I can use use it with a Bokeh AjaxDataSource no problem to create a streaming plot: source = AjaxDataSource(data_url="http://localhost:5000/data", polling_interval=1000, mode='append') p = figure() p.line('x', 'y', source=source) show(p) However, when I try to embed this in a flask

One chart with two different y axis ranges in Bokeh?

泄露秘密 提交于 2019-11-27 05:22:12
问题 I would like a Bar chart with Quantity information on the left y-axis, and then overlay a Scatter/Line plot with Yield % on the right. I can create each of these charts separately, but do not know how to combine them into a single plot. In matplotlib, we would create a second figure using twinx() , and then use yaxis.tick_left() and yaxis.tick_right() on the respective figures. Is there a method for doing something similar with Bokeh? 回答1: Yes, now it is possible to have two y axes in Bokeh

How do I use custom labels for ticks in Bokeh?

房东的猫 提交于 2019-11-27 04:49:00
I understand how you specify specific ticks to show in Bokeh, but my question is if there is a way to assign a specific label to show versus the position. So for example plot.xaxis[0].ticker=FixedTicker(ticks=[0,1]) will only show the x-axis labels at 0 and 1, but what if instead of showing 0 and 1 I wanted to show Apple and Orange. Something like plot.xaxis[0].ticker=FixedTicker(ticks=[0,1], labels=['Apple', 'Orange']) A histogram won't work for the data I am plotting. Is there anyway to use custom labels in Bokeh like this? As of even more recent versions of Bokeh ( 0.12.14 or so) this is

Serving interactive bokeh figure on heroku

这一生的挚爱 提交于 2019-11-27 04:26:34
问题 I'm trying to serve an interactive bokeh figure via heroku. The figure I'm trying to have served is essentially equivalent to this one (example, code). I'm new to both bokeh and heroku so I'm pretty sure I'm missing something pretty basic -- I think what I'm trying to do should be quite straightforward. First, I can serve my figure locally using the bokeh serve --show myapp command. Where myapp is the name of the python module that includes the bokeh figure. Note that the --show flag just

How do I make bokeh omit missing dates when using datetime as x-axis

和自甴很熟 提交于 2019-11-27 02:58:17
问题 I am looking at the candlestick example in the bokeh docs, found here: https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/candlestick.py and I am trying to figure out a good way to eliminate the "spaces" in the x-axis where there is no data. Specifically, for financial data like MSFT used in the example, there is no data for weekends and holidays. Is there a way to tell bokeh not to leave an empty space in the chart when there is no data for a date? Here is a paste of the

Hierarchic pie/donut chart from Pandas DataFrame using bokeh or matplotlib

家住魔仙堡 提交于 2019-11-27 02:19:53
问题 I have the following pandas DataFrame ("A" is the last column's header; the rest of columns are a combined hierarchical index): A kingdom phylum class order family genus species No blast hit 2496 k__Archaea p__Euryarchaeota c__Thermoplasmata o__E2 f__[Methanomassiliicoccaceae] g__vadinCA11 s__ 6 k__Bacteria p__ c__ o__ f__ g__ s__ 5 p__Actinobacteria c__Acidimicrobiia o__Acidimicrobiales f__ g__ s__ 0 c__Actinobacteria o__Actinomycetales f__Corynebacteriaceae g__Corynebacterium s__stationis 2

Get selected data contained within box select tool in Bokeh

杀马特。学长 韩版系。学妹 提交于 2019-11-27 01:59:51
问题 If I have a scatter plot in bokeh and I've enabled the Box Select Tool, suppose I select a few points with the Box Select Tool. How can I access the (x,y) position location information of the points that I've selected? %matplotlib inline import numpy as np from random import choice from string import ascii_lowercase from bokeh.models.tools import * from bokeh.plotting import * output_notebook() TOOLS="pan,wheel_zoom,reset,hover,poly_select,box_select" p = figure(title = "My chart", tools

multi_line hover in bokeh

孤街浪徒 提交于 2019-11-26 21:25:32
问题 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://docs.bokeh.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? 回答1: