简体   繁体   English

散景表小部件,其类别名称在每一行的第一列中,数据在下一列中

[英]Bokeh table widget with category names in the first column in each row and data in the next column

I want to create a Bokeh table widget with category names in the first column in each row and data in the second other column. 我想创建一个散景表窗口小部件,其类别名称在每行的第一列中,数据在第二列中。

Is there a way to achieve this. 有没有办法实现这一目标。

Thanks. 谢谢。

You can add everything you want to your table, as long as it's in your ColumnDataSource. 您可以将所需的所有内容添加到表中,只要它们在ColumnDataSource中即可。

More information about tables can be found here . 有关表的更多信息,请参见此处

from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.palettes import Spectral6
from bokeh.plotting import figure
from bokeh.transform import factor_cmap
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.layouts import row

output_file("colormapped_bars.html")

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 4, 2, 4, 6]

source = ColumnDataSource(data=dict(fruits=fruits, counts=counts))

p = figure(x_range=fruits, plot_height=250, toolbar_location=None, title="Fruit Counts")
p.vbar(x='fruits', top='counts', width=0.9, source=source, legend="fruits",
       line_color='white', fill_color=factor_cmap('fruits', palette=Spectral6, factors=fruits))

columns = [
    TableColumn(field="fruits", title="Fruits"),
    TableColumn(field="counts", title="Counts")
]
data_table = DataTable(source=source, columns=columns, width=400, height=280, index_position=None)

p.xgrid.grid_line_color = None
p.y_range.start = 0
p.y_range.end = 9
p.legend.orientation = "horizontal"
p.legend.location = "top_center"

show(row(p, data_table))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Select 在 dataframe 的列中存在特定类别的第一行 - Select first row with a particular category present in a column of the dataframe 如果列名在列中的一个表中并且列名的数据在列中的不同表中,如何创建表 - how to create a table if column names are in one table in a column and data for the column names are in different table in a columns 对独立于列的每行绝对值以及列名进行排序 - Sort each row absolute value independent of columns along with column names Python:比较CSV文件并保存与第一行的区别(列名) - Python : Compare CSV files and save the difference with first row(Column Names) 如何读取每行包含列名的 Pandas txt 文件 - How to read with Pandas txt file with column names in each row 按数据框中的每一列值过滤行 - Filter row by each column value in data frame 如何从 a.hdf5 文件表中提取列名并根据指定的列名提取特定行数据? - How do I extract the column names from a .hdf5 file table and extract specific row data based on a specified column name? 在python中为第一行找到零值的第一列 - Finding the the first column with zero value for each row in python 读取每列的第一个元素,然后读取 csv 文件中的整行 - Reading first element of each column and then the entire row in csv file 根据 pandas 中每个排序组的第一行创建一列 - Create a column based on first row of each sorted group in pandas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM