Module dcg_sci_tool.plot.plot_categorical_heatmap
Functions
def create_categorical_heatmap(data_tuples,
x_label_index,
y_label_index,
value_index,
x_labels_order=None,
y_labels_order=None,
title='Categorical Heatmap',
xlabel=None,
ylabel=None,
cmap='YlGn',
cbarlabel='Value',
figsize=(10, 8))-
从元组列表创建分类热力图(支持指定标签顺序) 使用方法:执行完此函数后,执行plt.show()命令,即可将图片展示出来
Args
data_tuples:listoftuples- 输入数据,每个元组包含:横轴标签、纵轴标签、数值
x_label_index:int- 元组中横轴标签的索引位置
y_label_index:int- 元组中纵轴标签的索引位置
value_index:int- 元组中数值的索引位置
x_labels_order:list, optional- 横轴标签的排列顺序
y_labels_order:list, optional- 纵轴标签的排列顺序
title:str, optional- 热力图的标题
xlabel:str, optional- 横轴标签
ylabel:str, optional- 纵轴标签
cmap:str, optional- 颜色映射
cbarlabel:str, optional- 颜色条标签
figsize:tuple, optional- 图形大小
Returns
tuple- 包含创建的图形、坐标轴对象和数据矩阵 fig (matplotlib.figure.Figure): 创建的图形 ax (matplotlib.axes.Axes): 坐标轴对象 data_matrix (numpy.ndarray): 热力图数据矩阵
def create_categorical_heatmap_advanced(data_tuples,
x_label_index,
y_label_index,
value_index,
x_labels_order=None,
y_labels_order=None,
title='Categorical Heatmap',
cmap='YlGn',
cbarlabel='Value',
figsize=(12, 10),
annotate=True,
valfmt='{x:.2f}',
threshold=None,
textcolors=('black', 'white'),
grid_visible=True)-
增强版的分类热力图创建函数(支持指定标签顺序) 使用方法:执行完此函数后,执行plt.show()命令,即可将图片展示出来
Args
data_tuples:listoftuples- 输入数据,每个元组包含:横轴标签、纵轴标签、数值
x_label_index:int- 元组中横轴标签的索引位置
y_label_index:int- 元组中纵轴标签的索引位置
value_index:int- 元组中数值的索引位置
x_labels_order:list- 横轴标签的排列顺序
y_labels_order:list- 纵轴标签的排列顺序
y_labels_order:list, optional- 纵轴标签的排列顺序
annotate:bool, optional- 是否在方格中添加数值标注
valfmt:str, optional- 数值格式化字符串
threshold:float, optional- 文本颜色切换的阈值
textcolors:tuple, optional- 用于阈值上下方的文本颜色
grid_visible:bool, optional- 是否显示网格线
def prepare_heatmap_data_ordered(data_tuples, x_index, y_index, value_index, x_labels_order=None, y_labels_order=None)-
从元组列表准备热力图数据(支持指定标签顺序)。
Args
data_tuples:listoftuples- 原始数据元组列表
x_index:int- 横轴标签索引
y_index:int- 纵轴标签索引
value_index:int- 数值索引
x_labels_order:list, optional- 横轴标签的排列顺序
y_labels_order:list, optional- 纵轴标签的排列顺序
Returns
tuple- (data_matrix, x_labels, y_labels)
数据矩阵,横轴标签列表,纵轴标签列表