bokeh

Bokeh - Stacked and grouped charts

放肆的年华 提交于 2021-01-27 06:55:31
问题 Is it possible to create a plot in bokeh that is both stacked and grouped? Kinda like http://www.highcharts.com/demo/column-stacked-and-grouped/. The dataset is something like this count date class user 39 2016/12/28 4 user1 26 2016/12/28 4 user2 3 2016/12/28 4 user2 8 2016/12/28 4 user1 1 2016/12/28 4 user1 22 2016/12/28 4 user1 26 2016/12/28 4 user2 1 2016/12/28 4 user1 7 2016/12/28 4 user2 12 2016/12/28 4 user3 23 2016/12/28 4 user3 31 2016/12/28 4 user3 2 2016/12/31 4 user1 1 2016/12/31 4

Change the order of bars in a grouped barplot with hvplot/holoviews

烂漫一生 提交于 2021-01-24 07:03:21
问题 I try to create a grouped bar plot but can't figure out how to influence the order of the barplot. Given these example data: import pandas as pd import hvplot.pandas df = pd.DataFrame({ "lu": [200, 100, 10], "le": [220, 80, 130], "la": [60, 20, 15], "group": [1, 2, 2], }) df = df.groupby("group").sum() I'd like to create a horizontal grouped bar plot showing the two groups 1 and 2 with all three columns. The columns should appear in the order of "le", "la" and "lu". Naturally I'd try this

Bokeh Circle does not fit into square?

对着背影说爱祢 提交于 2021-01-18 10:52:08
问题 I am plotting some geometry using bokeh and came across this. I am plotting a rectangle with equal sides (i.e. a square), and in that square, plotting a circle with diameter = width of the square. The circle should tangent to the square at edges, but it is not. here is the code: from bokeh.plotting import output_notebook, figure, show output_notebook() p = figure(width=500, height=500) p.rect(0, 0, 300, 300, line_color='black') p.circle(x=0, y=0, radius=150, line_color='black', fill_color=

专题 | Python 绘图入门

橙三吉。 提交于 2021-01-14 03:01:55
腾讯课堂 | Python网络爬虫与文本分析 我的施工之路 1 我的施工计划 2 数字专题 3 字符串专题 4 列表专题 5 流程控制专题 6 编程风格专题 7 函数使用 8 面向对象编程(上篇) 9 面向对象编程(下篇) 10 十大数据结构 11 包和模块使用总结 12 Python正则专题总结 13 设计模式 14 Python时间模块总结 15 Python 装饰器 16 Python 迭代器 17 Python 生成器 Python 绘图入门 这是施工系列第18篇,同时也进入到一个新的阶段:Python绘图篇。作为绘图模块的第一篇,与大家一起过过最基本的Python绘图原理。 掌握基本的绘图原理很有必要,各个常用绘图库的原理基本都是相通的。所以了解它们后,使用库里的API函数将会更加得心应手,并且熟练其中一个库后,便能迅速上手其他的绘图库。 1 绘图组成要素 一般绘图要素的基本组成部分包括:画布(Canvas),坐标系(Axes),轴(Axis),标题(Title),标签(Label),刻度(Tick),图例(Legend),网格(Grid),数据域(Data),如下图所示: 2 画布 画布 Canvas 是绘制图像的地方,一个画布可以包括多个坐标系,如下图所示,一个Canvas上包括2个坐标系(Axes): 对应在实际绘图中,如下所示,画布上共包括3个坐标系

浅度测评:requests、aiohttp、httpx 我应该用哪一个?

回眸只為那壹抹淺笑 提交于 2021-01-04 07:04:03
摄影: 产品经理 与产品经理环游世界 在 Python 众多的 HTTP 客户端中,最有名的莫过于 requests 、 aiohttp 和 httpx 。在不借助其他第三方库的情况下, requests 只能发送同步请求; aiohttp 只能发送异步请求; httpx 既能发送同步请求,又能发送异步请求。 所谓的同步请求,是指在单进程单线程的代码中,发起一次请求后,在收到返回结果之前,不能发起下一次请求。所谓异步请求,是指在单进程单线程的代码中,发起一次请求后,在等待网站返回结果的时间里,可以继续发送更多请求。 今天我们来一个浅度测评,仅仅以多次发送 POST 请求这个角度来对比这三个库的性能。 测试使用的 HTTP 服务地址为http://122.51.39.219:8000/query,向它发送 POST 请求的格式如下图所示: 请求发送的 ts 字段日期距离今天大于10天,那么返回 {"success": false} ,如果小于等于10天,那么返回 {"success": true} 。 首先我们通过各个客户端使用相同的参数只发送一次请求,看看效果。 发送一次请求 requests import requests resp = requests.post( 'http://122.51.39.219:8000/query' , json={ 'ts' : '2020

How to dynamically hide glyphs and legend items with Bokeh

て烟熏妆下的殇ゞ 提交于 2021-01-01 06:31:42
问题 I am trying to implement checkboxes in bokeh where each checkbox should show/hide the line associated with it. I'm aware it's possible to achieve this with legends, but I want this effect to happen in two plots at the same time. Also, the legend should update as well. In the example below the checkboxes appear, but do nothing. I am clearly not grasping how to update de dataframe used as source. Thanks for any help. from bokeh.io import show, curdoc from bokeh.models import HoverTool,

How to dynamically hide glyphs and legend items with Bokeh

回眸只為那壹抹淺笑 提交于 2021-01-01 06:29:35
问题 I am trying to implement checkboxes in bokeh where each checkbox should show/hide the line associated with it. I'm aware it's possible to achieve this with legends, but I want this effect to happen in two plots at the same time. Also, the legend should update as well. In the example below the checkboxes appear, but do nothing. I am clearly not grasping how to update de dataframe used as source. Thanks for any help. from bokeh.io import show, curdoc from bokeh.models import HoverTool,

How to dynamically hide glyphs and legend items with Bokeh

£可爱£侵袭症+ 提交于 2021-01-01 06:29:13
问题 I am trying to implement checkboxes in bokeh where each checkbox should show/hide the line associated with it. I'm aware it's possible to achieve this with legends, but I want this effect to happen in two plots at the same time. Also, the legend should update as well. In the example below the checkboxes appear, but do nothing. I am clearly not grasping how to update de dataframe used as source. Thanks for any help. from bokeh.io import show, curdoc from bokeh.models import HoverTool,

How to dynamically hide glyphs and legend items with Bokeh

限于喜欢 提交于 2021-01-01 06:29:10
问题 I am trying to implement checkboxes in bokeh where each checkbox should show/hide the line associated with it. I'm aware it's possible to achieve this with legends, but I want this effect to happen in two plots at the same time. Also, the legend should update as well. In the example below the checkboxes appear, but do nothing. I am clearly not grasping how to update de dataframe used as source. Thanks for any help. from bokeh.io import show, curdoc from bokeh.models import HoverTool,

Bokeh hover tooltip to show data from a different column

柔情痞子 提交于 2020-12-26 11:03:36
问题 I have the code below. I want the hover tooltip for the bars to show which account they are from. It is unclear to me how the hover.tooltips parameter should be used to retrieve data from the account column in the dataframe. import pandas as pd from bokeh.plotting import figure, output_notebook, show output_notebook() sales = [{'account': 'Jones LLC', 'sales': 150, 'day' : 1}, {'account': 'Alpha Co', 'sales': 200, 'day' : 2}, {'account': 'Blue Inc', 'sales': 50, 'day' : 3}] df = pd.DataFrame