bokeh

Embedding Bokeh plot in Django website results in blank page with no error message

僤鯓⒐⒋嵵緔 提交于 2019-11-30 20:30:51
I'm trying to embed a Bokeh plot into a Django site that has an upload button. I'm using the example given here as a starting point and then adding on the instructions on embedding from here . This is a follow-up on my question here as I now have a new problem. The plot just wont display when I go to the url associated with it, but there is no error message and the page loads. I used need-a-minimal-django-file-upload-example/for_django_1.8 and it works as intended when I navigate to the url http://<port>/myapp/list/ myapp/url.py looks like this # -*- coding: utf-8 -*- from django.conf.urls

bokeh overlay multiple plot objects in a GridPlot

五迷三道 提交于 2019-11-30 17:46:08
问题 Say I have a class that holds some data and implements a function that returns a bokeh plot import bokeh.plotting as bk class Data(): def plot(self,**kwargs): # do something to retrieve data return bk.line(**kwargs) Now I can instantiate multiple of these Data objects like exps and sets and create individual plots. If bk.hold() is set they'll, end up in one figure (which is basically what I want). bk.output_notebook() bk.figure() bk.hold() exps.scatter(arg1) sets.plot(arg2) bk.show() Now I

JavaScript callback to get selected glyph index in Bokeh

本小妞迷上赌 提交于 2019-11-30 16:32:45
I've created a visual graph using Bokeh that shows a network I created using Networkx. I now want to use TapTool to show information pertinent to any node on the graph that I click on. The graph is just nodes and edges. I know I should be able to use var inds = cb_obj.selected['1d'].indices; in the JavaScript callback function to get the indices of the nodes (glyphs) that were clicked on, but that's not working somehow and I get the error message, Uncaught TypeError: Cannot read property '1d' of undefined . A nudge in the right direction would be greatly appreciated. Below is my code. Please

bokeh - plot a different column using customJS

坚强是说给别人听的谎言 提交于 2019-11-30 16:00:19
问题 I have a dataframe of multiple columns. First two columns are x and y coordinates and the rest columns are different property values for (x,y) pairs. import pandas as pd import numpy as np df = pd.DataFrame() df['x'] = np.random.randint(1,1000,100) df['y'] = np.random.randint(1,1000,100) df['val1'] = np.random.randint(1,1000,100) df['val2'] = np.random.randint(1,1000,100) df['val3'] = np.random.randint(1,1000,100) print df.head() x y val1 val2 val3 0 337 794 449 969 933 1 19 563 592 677 886 2

How to get a list of Bokeh widget events and attributes (which can be used to trigger a Python callback)

醉酒当歌 提交于 2019-11-30 15:24:28
The real (general) question I am new to Bokeh and I am trying to build a plot which can be dynamically updated based on input provided by a widget. However, usage of Python callbacks is not thoroughly documented for most widgets and therefore I'm stuck. How can I know which widget method I should use to attach my callback? I can guess the available choices by probing the widgets attributes in an interactive console, but that's not elegant and I'm sure it's written somewhere in the documentation. Provided that I would know about the method to use (e.g. on_event or on_change ), I still have to

How to do waffle charts in python? (square piechart)

谁都会走 提交于 2019-11-30 12:04:31
问题 Something like this: There is a very good package to do it in R. In python, the best that I could figure out is this, using the squarify package (inspired by a post on how to do treemaps): import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns # just to have better line color and width import squarify # for those using jupyter notebooks %matplotlib inline df = pd.DataFrame({ 'v1': np.ones(100), 'v2': np.random.randint(1, 4, 100)})

When plotting with Bokeh, how do you automatically cycle through a color pallette?

﹥>﹥吖頭↗ 提交于 2019-11-30 11:05:50
I want to use a loop to load and/or modify data and plot the result within the loop using Bokeh (I am familiar with Matplotlib's axes.color_cycle ). Here is a simple example import numpy as np from bokeh.plotting import figure, output_file, show output_file('bokeh_cycle_colors.html') p = figure(width=400, height=400) x = np.linspace(0, 10) for m in xrange(10): y = m * x p.line(x, y, legend='m = {}'.format(m)) p.legend.location='top_left' show(p) which generates this plot How do I make it so the colors cycle without coding up a list of colors and a modulus operation to repeat when the number of

Exporting figures from Bokeh as svg or pdf?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 10:55:23
Is it possible to output individual figures from Bokeh as pdf or svg images? I feel like I'm missing something obvious, but I've checked the online help pages and gone through the bokeh.objects api and haven't found anything... There is no way to save PDF currently, but 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 some optional dependencies that need to be installed. You

Bokeh DataTable - Return row and column on selection callback

谁说我不能喝 提交于 2019-11-30 09:46:01
问题 Using an on_change callback, I can get the numerical row index of a selection within a DataTable, in Bokeh. Is it possible to: a) Get the column index b) Get the values of the indexes (column and row headers) Example code: from bokeh.io import curdoc from bokeh.layouts import row, column import pandas as pd from bokeh.models import ColumnDataSource, ColorBar, DataTable, DateFormatter, TableColumn, HoverTool, Spacer, DatetimeTickFormatter ''' Pandas ''' df = pd.DataFrame(data = {'Apples': [5

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

被刻印的时光 ゝ 提交于 2019-11-30 09:17:14
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- 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 href="#" data-toggle="tooltip" title="<%= value %>"><%= value %></span>""" df = pd.DataFrame([ ['this is a