bokeh

How to resolve the clutter in my networkx graph using interactivity

依然范特西╮ 提交于 2021-01-29 17:10:40
问题 I am plotting a network graph of urls and applying louvain clustering. I could successfully plot the graph however it creates a clutter. The code is: pip install python-louvain import community.community_louvain partition = community.community_louvain.best_partition(G) # draw the graph pos = nx.spring_layout(G) # color the nodes according to their partition cmap = cm.get_cmap('viridis', max(partition.values()) + 1) plt.figure(figsize=(15,15)) nx.draw_networkx_nodes(G, pos, partition.keys(),

Bokeh update map tooltip using select or slider

不打扰是莪最后的温柔 提交于 2021-01-29 13:01:07
问题 I am trying to update a worldmap tooltip using a slicer or dropdown select. I got following question which sorted the most of the stuff for a Bokeh Slider custom JS callback import pandas as pd import random from datetime import timedelta df = pd.DataFrame({'base' : ["2017-01-01" for t in range(10000)], 'Date' : [random.randint(0, 1035) for t in range(10000)], 'Sales' : [random.random() for t in range(10000)]}) df['base'] = pd.to_datetime(df['base']) df["Date2"] = df.apply(lambda x: x["base"]

Bokeh Position Legend outside plot area for stacked vbar

巧了我就是萌 提交于 2021-01-29 12:50:43
问题 I have a stacked vbar chart in Bokeh, a simplified version of which can be reproduced with: from bokeh.plotting import figure from bokeh.io import show months = ['JAN', 'FEB', 'MAR'] categories = ["cat1", "cat2", "cat3"] data = {"month" : months, "cat1" : [1, 4, 12], "cat2" : [2, 5, 3], "cat3" : [5, 6, 1]} colors = ["#c9d9d3", "#718dbf", "#e84d60"] p = figure(x_range=months, plot_height=250, title="Categories by month", toolbar_location=None) p.vbar_stack(categories, x='month', width=0.9,

Bokeh not updating plot line update from CheckboxGroup

六月ゝ 毕业季﹏ 提交于 2021-01-29 11:03:01
问题 I'm following this great tutorial to play a little bit with Bokeh. Basically, I have a figure with two independent line added to it. Everything is rendered properly but when I want to update nothing happens even if I checked that the new ColumnDataSource is well updated with the new values. I render it using the command : bokeh serve --show my_app Here is how I create my figure : src_p6 = make_dataset(["select_a", "select_b"]) p6 = make_plot(src_p6) select_selection = CheckboxGroup(labels=[

Bokeh Server plot not updating as wanted, also it keeps shifting and axis information vanishes

一曲冷凌霜 提交于 2021-01-29 10:00:30
问题 I want the plot to update, once I click the "refresh button", with the new data. But the old data stays in the plot, also it keeps shifting down right and the ticks vanish. At the beginning, the plot looks what I expected ( except the X axis information. As a side problem, I I looked up DataSpec() in Bokeh properties but not sure how to pass the accept_datetime=False to the x argument in the line plot. My code kind of looks like this. ) The data directory looks like root-| |-weeklydata1.pkl |

Plot a local image using bokeh image_url by running python with the -m option

故事扮演 提交于 2021-01-29 09:46:50
问题 I have to run a bokeh script as a module using the -m option from the top directory, because it needs to import some other portable module under the same directory python -m bokeh_module.bokeh_sub_module The directory tree is shown below. By running the above command, it doesn't show the image no matter where the png file is placed, is there a way to resolved the issue? Thank you for any help. . ├── other_module │ ├── __init__.py │ └── other_sub_module.py ├── bokeh_module │ ├── __init__.py │

How to pass node attributes from NetworkX to bokeh

怎甘沉沦 提交于 2021-01-29 08:20:26
问题 I am looking for a way to pass a color, as assinged in NetworkX's node construction, to a Bokeh plot. There are some great ways to implement color in the Bokeh plot after it is generated, such as this, but this solution requires that I apply the transformation to the entire data set based on an attribute. I wanted to do something even simpler and assign a color and size based on what I assign those to be in NetworkX. I normally plot node set 1 as red, then node set 2 as blue in NetworkX, then

How to display Dataset labels inside a HoverTool in a Sankey diagram using Holoviews and Bokeh

匆匆过客 提交于 2021-01-29 08:01:01
问题 I am using Holoviews to display a Sankey Diagram and would like to customize the information displayed when positioning a cursor over the diagram. However, I don't know how to display the correct labels. Taking the 2nd example from the docs, I can add a custom HoverTool import holoviews as hv from holoviews import opts from bokeh.models import HoverTool nodes = ["PhD", "Career Outside Science", "Early Career Researcher", "Research Staff", "Permanent Research Staff", "Professor", "Non-Academic

Remove toolbar item in bokeh python

落爺英雄遲暮 提交于 2021-01-29 07:11:48
问题 To add a toolbar item, we do plot.add_tools(tool) What would be the opposite of this, where i want to remove a particular tool which I have reference to ? 回答1: The Toolbar object of the plot can be used to remove the tool - from bokeh.plotting import figure, output_file, show, output_notebook output_notebook() # create a new plot with the toolbar below p = figure(plot_width=400, plot_height=400, title=None, toolbar_location="below") p.circle([1, 2, 3, 4, 5], [2, 5, 8, 2, 7], size=10) show(p)

How to properly handle datetime and categorical axes in bokeh/holoviews heatmap plot?

☆樱花仙子☆ 提交于 2021-01-29 04:48:59
问题 I'm trying to plot a simple heatmap using bokeh/holoviews. My data (pandas dataframe) has categoricals (on y) and datetime (on x). The problem is that the number of categorical elements is >3000 and the resulting plot appears with messed overlapped tickers on the y axis that makes it totally useless. Currently, is there a reliable way in bokeh to select only a subset of the tickers based on the zoom level? I've already tried plotly and the result looks perfect but however I need to use bokeh