bokeh

Adding node labels to bokeh network plots

六眼飞鱼酱① 提交于 2019-12-04 17:15:04
问题 I am using the following code to produce an interactive bokeh network graph. How do I add the name of the nodes to the nodes in the bokeh plot? from bokeh.io import show, output_notebook from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, TapTool, BoxSelectTool from bokeh.models.graphs import from_networkx, NodesAndLinkedEdges, EdgesAndLinkedNodes from bokeh.palettes import Spectral4 from bokeh.models import LabelSet plot = Plot(plot_width=900, plot_height=500, x_range

Color nodes by Networkx node attribute with Bokeh

时光怂恿深爱的人放手 提交于 2019-12-04 17:13:31
I'm trying to use bokeh to create an interactive network visualization. I understand how to add attribtue data to the bokeh graph, but I'm not sure how to assign a fill color based on the node attribute. I've been following all of the bokeh examples that I can find, but I can't seem to figure it out. How can I adjust my code below to color the nodes by their NetworkX node attributes? import networkx as nx from bokeh.io import show, output_notebook from bokeh.plotting import figure from bokeh.models import Circle, HoverTool, TapTool, BoxSelectTool from bokeh.models.graphs import from_networkx

bokeh year on year line graph procedure

[亡魂溺海] 提交于 2019-12-04 16:36:30
what is the best way for doing year over year line charts with daily data in bokeh? currently im adding a dateline (arbitrarily for 2016) and year column to inital dataframe of daily values. Then pivoting to wide data by year filling in NAs (missing data varies across years) and then building bokeh graph line by line across the year cols: Say I have a table of three years data: Column: Date and Value df = df.set_index('Date') df['dateline'] = df.index.to_series().dt.strftime('%d-%b-2016') df['year'] = df.index.to_series().dt.strftime('%Y') pv = pd.pivot_table(df, index=df['dateline'], columns

Bokeh: CustomJS Callback for Mouse Move or Click

穿精又带淫゛_ 提交于 2019-12-04 15:42:59
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 the plot should suffice. You can use HoverTool and CustomJS as in the code example below. This example

Hide Axis in Bokeh

余生颓废 提交于 2019-12-04 15:35:22
问题 How can I hide both x and y axis in a bokeh plot ? I've checked and tried based on this : p1= figure (... visible=None) p1.select({"type": "Axis", "visible": 0}) xaxis = Axis(plot=p1, visible = 0) and like http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#axes 回答1: Create a figure object. So, in your example the figure object is p1 , then p1.axis.visible = False If you want to specify a y or x axis, then use p1.xaxis.visible = False or p1.yaxis.visible = False 回答2: Set the axes

Have Bokeh Callback update a list instead of a ColumnDataSource?

ⅰ亾dé卋堺 提交于 2019-12-04 14:48:12
My question has to do with modifying this example from the Bokeh Gallery. I have a matrix m or raw data, in which every row corresponds to a pair of x,y coordinates in a transformed space (see #MockData part of code). The x,y coordinates are plotted on the left plot. I am trying to change the example so that, when I select some points in the left figure, the right figure will display line plots of the corresponding rows. I've narrowed the problem down to the point, where the right figure will show the desired data as specified by the "indices" list. I cannot, however, figure out how to link

Changing source of plot in bokeh with a callback

吃可爱长大的小学妹 提交于 2019-12-04 14:48:01
问题 Imagine I have 2 (or more) sources of data with the same number of columns and rows: #Data dates = [date(2016, i, 1) for i in range(1,13)] data1 = pd.DataFrame(index = dates, data = random.randn(12, 2), columns = ['A', 'B']) data2 = pd.DataFrame(index = dates, data = random.randn(12, 2), columns = ['A', 'B']) and I want to plot columns A & B in bokeh as so: #Bokeh source = ColumnDataSource(source1) source1 = ColumnDataSource(data1) source2 = ColumnDataSource(data2) p = figure(x_axis_type =

Bokeh - how to make HoverTool tooltips stick to points on click?

荒凉一梦 提交于 2019-12-04 14:11:56
问题 The code below comes from a jupyter notebook: from bokeh.io import show, output_notebook from bokeh.plotting import ColumnDataSource, figure from bokeh.models import HoverTool, Range1d output_notebook() fig = figure(tools=[HoverTool(tooltips=[("html", '@html{safe}')])]) fig.quad(left="left", top="top", bottom="bottom", right="right", source=ColumnDataSource({"left": [1,3], "bottom": [1,3], "right": [2,4], "top": [2,4], "html":["<b>I'm bold</b>", "<span style='color:red;font-size:32px;'>BIG

Plotting Pandas Multiindex Bar Chart

一个人想着一个人 提交于 2019-12-04 12:43:25
问题 How can I plot a Python Pandas multiindex dataframe as a bar chart with group labels? Do any of the plotting libraries directly support this? This SO post shows a custom solution using matplotlib, but is there direct support for it? As an example: quarter company Q1 Blue 100 Green 300 Q2 Blue 200 Green 350 Q3 Blue 300 Green 400 Q4 Blue 400 Green 450 Name: count, dtype: int64 ...can this dataframe be plotted with group labels like this? Thanks in advance, Rafi 回答1: import pandas as pd data =

How to capture value of dropdown widget in bokeh python?

邮差的信 提交于 2019-12-04 12:07:40
问题 The official documentation of bokeh 0.12.1 in the link give the below code for creating a dropdown. http://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html#userguide-interaction-widgets But it doesn't clearly mention how to capture the value of the dropdown widget when someone click and selects a value from the dropdown. from bokeh.io import output_file, show from bokeh.layouts import widgetbox from bokeh.models.widgets import Dropdown output_file("dropdown.html") menu = [(