本文整理匯總了Python中bokeh.models.widgets.TableColumn方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.TableColumn方法的具體用法?Python widgets.TableColumn怎麽用?Python widgets.TableColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bokeh.models.widgets
的用法示例。
在下文中一共展示了widgets.TableColumn方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _build_optresult_selector
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def _build_optresult_selector(self, optresults) -> Tuple[DataTable, ColumnDataSource]:
# 1. build a dict with all params and all user columns
data_dict = defaultdict(list)
for optres in optresults:
for param_name, _ in optres[0].params._getitems():
param_val = optres[0].params._get(param_name)
data_dict[param_name].append(param_val)
for usercol_label, usercol_fnc in self._usercolumns.items():
data_dict[usercol_label].append(usercol_fnc(optres))
# 2. build a pandas DataFrame
df = DataFrame(data_dict)
# 3. now sort and limit result
if self._sortcolumn is not None:
df = df.sort_values(by=[self._sortcolumn], ascending=self._sortasc)
if self._num_result_limit is not None:
df = df.head(self._num_result_limit)
# 4. build column info for Bokeh table
tab_columns = []
for colname in data_dict.keys():
formatter = NumberFormatter(format='0.000')
if len(data_dict[colname]) > 0 and isinstance(data_dict[colname][0], int):
formatter = StringFormatter()
tab_columns.append(TableColumn(field=colname, title=f'{colname}', sortable=False, formatter=formatter))
# TODO: currently table size is hardcoded
cds = ColumnDataSource(df)
selector = DataTable(source=cds, columns=tab_columns, width=1600, height=150)
return selector, cds
示例2: EpitopeTable
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def EpitopeTable(self):
Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.neosData.columns] # bokeh columns
data_table = DataTable(columns=Columns, source=ColumnDataSource(self.neosData) ,width=1200, height=200) # bokeh table
return(data_table)
示例3: SummaryTable
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def SummaryTable(self):
Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.summaryData.columns] # bokeh columns
data_table = DataTable(columns=Columns, source=ColumnDataSource(self.summaryData) ,width=1200, height=200) # bokeh table
return(data_table)
示例4: plot_Scatterplot
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def plot_Scatterplot():
plotname = inspect.stack()[0][3][5:]
pandas_bokeh.output_file(os.path.join(PLOT_DIR, f"{plotname}.html"))
df = df_iris()
df = df.sample(frac=1)
# Create Bokeh-Table with DataFrame:
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.models import ColumnDataSource
data_table = DataTable(
columns=[TableColumn(field=Ci, title=Ci) for Ci in df.columns],
source=ColumnDataSource(df.head(10)),
)
# Create Scatterplot:
p_scatter = df.plot_bokeh.scatter(
x="petal length (cm)",
y="sepal width (cm)",
category="species",
title="Iris DataSet Visualization",
show_figure=False,
)
# Combine Div and Scatterplot via grid layout:
pandas_bokeh.plot_grid([[data_table, p_scatter]], plot_width=400, plot_height=350)
示例5: _create_events_table
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def _create_events_table() -> DataTable:
"""Utility function for creating and styling the events table."""
formatter = HTMLTemplateFormatter(
template="""
<style>
.AS_POS {color: #0000FF; font-weight: bold;}
.AS_NEG {color: #0000FF; font-weight: bold;}
.OP_POS {color: #1aaa0d; font-style: bold;}
.OP_NEG {color: #f40000;font-style: bold;}
.NEG_POS {font-style: italic;}
.NEG_NEG {color: #f40000; font-style: italic;}
.INT_POS {color: #1aaa0d; font-style: italic;}
.INT_NEG {color: #f40000; font-style: italic;}
</style>
<%= value %>"""
)
columns = [
TableColumn(field="POS_events", title="Positive Examples", formatter=formatter),
TableColumn(field="NEG_events", title="Negative Examples", formatter=formatter),
]
return DataTable(
source=ColumnDataSource(),
columns=columns,
height=400,
index_position=None,
width=2110,
sortable=False,
editable=True,
reorderable=False,
)
示例6: _create_examples_table
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def _create_examples_table() -> DataTable:
"""Utility function for creating and styling the events table."""
formatter = HTMLTemplateFormatter(
template="""
<style>
.AS {color: #0000FF; font-weight: bold;}
.OP {color: #0000FF; font-weight: bold;}
</style>
<div><%= value %></div>"""
)
columns = [
TableColumn(
field="Examples", title='<span class="header">Examples</span>', formatter=formatter
)
]
empty_source = ColumnDataSource()
empty_source.data = {"Examples": []}
return DataTable(
source=empty_source,
columns=columns,
height=500,
index_position=None,
width=1500,
sortable=False,
editable=False,
reorderable=False,
header_row=True,
)
示例7: test_scatterplot
# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import TableColumn [as 別名]
def test_scatterplot(df_iris):
"Test for scatterplot"
# Create Bokeh-Table with DataFrame:
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.models import ColumnDataSource
data_table = DataTable(
columns=[TableColumn(field=Ci, title=Ci) for Ci in df_iris.columns],
source=ColumnDataSource(df_iris.head(10)),
)
data_table_accessor = DataTable(
columns=[TableColumn(field=Ci, title=Ci) for Ci in df_iris.columns],
source=ColumnDataSource(df_iris.head(10)),
)
# Create Scatterplot:
arguments = dict(
x="petal length (cm)",
y="sepal width (cm)",
category="species",
title="Iris DataSet Visualization",
show_figure=False,
)
p_scatter = df_iris.plot_bokeh(kind="scatter", **arguments)
p_scatter_accessor = df_iris.plot_bokeh.scatter(**arguments)
p_scatter_pandas_backend = df_iris.plot(kind="scatter", **arguments)
p_scatter_accessor_pandas_backend = df_iris.plot.scatter(**arguments)
# Combine Div and Scatterplot via grid layout:
output = pandas_bokeh.plot_grid(
[[data_table, p_scatter], [data_table_accessor, p_scatter_accessor]],
show_plot=False,
return_html=True,
)
with open(os.path.join(DIRECTORY, "Plots", "Scatterplot.html"), "w") as f:
f.write(output)
assert True