Now, plot sub-module mainly work for drawing a positional grouped and stacked plot, such as bar plot. Thus, this sub-module contains pandas.dataFrame utils for plot and some simple plot based on plt.
generated by ChatGPT
该模块提供了一些绘图函数,用于生成柱状图、QQ图和Tukey's test结果的可视化。
rgb2hex(r, g, b)将RGB颜色值转换为十六进制颜色代码。
r (int): 红色分量,取值范围为0-255。g (int): 绿色分量,取值范围为0-255。b (int): 蓝色分量,取值范围为0-255。hex (str): 十六进制颜色代码。hex2rgb(hex)将十六进制颜色代码转换为RGB颜色值。
hex (str): 十六进制颜色代码。rgb (list[int]): 包含红色、绿色和蓝色分量的列表。rgbs2hexs(rgbs)将RGB颜色值列表转换为十六进制颜色代码列表。
rgbs (list[tuple[float]]): 包含RGB颜色值的元组列表。每个元组必须包含三个介于0和1之间的浮点数,分别表示红色、绿色和蓝色分量。hexs (list[str]): 十六进制颜色代码列表。get_palette(n=10, mode=None, return_n=True)获取一组颜色序列。
n (int): 需要的颜色数量。mode (str): 颜色的类型。hls (默认值): 使用 sns.color_palette('hls', n) 生成颜色序列。green:使用5种绿色生成颜色序列。pair:使用 plt.get_cmap('tab20') 生成颜色序列。None:当 n<=9 时使用 plt.get_cmap('Set1'),当 n<=12 时使用 plt.get_cmap('Set3')。return_n (bool): 是否返回指定数量的颜色序列。palette (list[str]): 包含颜色代码的列表。AxisLable表示一个坐标轴标签。
name (str): 标签名称。hold_space (int): 保留的空间大小。add_space(space=1): 增加保留的空间大小。pro_hue_pos(factors, df, width, bar_space)计算多个分类变量的 x 轴标签和每个柱子的位置。
factors (list[str]): DataFrame 中要分组的列名列表。df (pd.DataFrame): 输入的 DataFrame。width (float): 每个柱子的宽度。bar_space (float): 柱子之间的间距。xlabels (list[AxisLable]): 每个坐标轴的标签列表。pos (list[float]): 每个柱子的位置列表。plot_bar(factors, tags, df, **kwargs)绘制带有不同颜色的堆叠柱状图。
factors (list[str]): 用于分组的列名列表。tags (list[str]): 用于堆叠的列名列表。df (pd.DataFrame): 输入的 DataFrame。**kwargs (dict): 其他关键字参数。width (float): 每个柱子的宽度,默认值为0.4。bar_space (float): 柱子之间的间距,默认值为0.2。xrotations (list[int]): 每个坐标轴的旋转角度列表,默认值为每个坐标轴都不旋转。colors (list[str]): 颜色列表,默认值为 plt.rcParams['axes.prop_cycle'].by_key()['color']。hatchs (list[str]): 柱子的填充样式列表,默认值为 ['-', '+', 'x', '\\', '*', 'o', 'O', '.']。labels (None or list[str]): 标签列表,默认值为 None。font_size (None or list[int]): 字体大小列表,默认值为 None。offset (list[int]): 每个坐标轴的偏移量列表,默认值为每个坐标轴的字体大小加上8的倍数。edgecolor (str): 柱子边缘的颜色,默认值为 'white'。pos (np.array): 每个柱子的位置数组。ax1 (Axes): 当前的 Axes 实例。plot_positional_hue(factors, tags, df, **kwargs)用于包装绘图函数,支持传递额外的参数。
factors (list[str]): 用于分组的列名列表。tags (list[str]): 用于堆叠的列名列表。df (pd.DataFrame): 输入的 DataFrame。**kwargs (dict): 其他关键字参数。core_wrapper (function): 包装后的函数。qqplot(tags, df, figsize=(12, 6), nrows=1, ncols=1, **kwargs)生成每个标签的QQ图。
tags (list[str]): 要绘制QQ图的标签列表。df (pd.DataFrame): 包含要绘制的数据的 DataFrame。figsize (tuple(int, int)): 图形的大小,默认值为 (12, 6)。nrows (int): 图形网格的行数,默认值为 1。ncols (int): 图形网格的列数,默认值为 1。**kwargs (dict): 其他关键字参数。Nonesave_show(path, dpi=300, bbox_inches='tight')保存并显示当前的图形。
path (str): 要保存图形的文件路径。dpi (int): 保存图形的分辨率,默认值为 300。bbox_inches (str or Bbox): 要保存的图形区域,默认值为 'tight'。Noneplot_turkey(means, std_errs, tukey_results)绘制显示不同组均值和标准误差的柱状图。
means (list[float]): 每个组的均值列表。std_errs (list[float]): 每个组的标准误差列表。tukey_results (Tukey's test结果): Tukey's test结果对象。ax (Axes): 当前的 Axes 实例。AxisLable表示一个坐标轴标签。
name (str): 标签名称。hold_space (int): 保留的空间大小。add_space(space=1): 增加保留的空间大小。pro_hue_pos(factors, df, width, bar_space)计算多个分类变量的 x 轴标签和每个柱子的位置。
factors (list[str]): DataFrame 中要分组的列名列表。df (pd.DataFrame): 输入的 DataFrame。width (float): 每个柱子的宽度。bar_space (float): 柱子之间的间距。xlabels (list[AxisLable]): 每个坐标轴的标签列表。pos (list[float]): 每个柱子的位置列表。plot_bar(factors, tags, df, **kwargs)绘制带有不同颜色的堆叠柱状图。
factors (list[str]): 用于分组的列名列表。tags (list[str]): 用于堆叠的列名列表。df (pd.DataFrame): 输入的 DataFrame。**kwargs (dict): 其他关键字参数。pos (np.array): 每个柱子的位置数组。ax1 (Axes): 当前的 Axes 实例。plot_positional_hue(factors, tags, df, **kwargs)用于包装绘图函数,支持传递额外的参数。
factors (list[str]): 用于分组的列名列表。tags (list[str]): 用于堆叠的列名列表。df (pd.DataFrame): 输入的 DataFrame。**kwargs (dict): 其他关键字参数。core_wrapper (function): 包装后的函数。qqplot(tags, df, figsize=(12, 6), nrows=1, ncols=1, **kwargs)生成每个标签的QQ图。
tags (list[str]): 要绘制QQ图的标签列表。df (pd.DataFrame): 包含要绘制的数据的 DataFrame。figsize (tuple(int, int)): 图形的大小,默认值为 (12, 6)。nrows (int): 图形网格的行数,默认值为 1。ncols (int): 图形网格的列数,默认值为 1。**kwargs (dict): 其他关键字参数。Nonesave_show(path, dpi=300, bbox_inches='tight')保存并显示当前的图形。
path (str): 要保存图形的文件路径。dpi (int): 保存图形的分辨率,默认值为 300。bbox_inches (str or Bbox): 要保存的图形区域,默认值为 'tight'。Noneplot_turkey(means, std_errs, tukey_results)绘制显示不同组均值和标准误差的柱状图。
means (list[float]): 每个组的均值列表。std_errs (list[float]): 每个组的标准误差列表。tukey_results (Tukey's test结果): Tukey's test结果对象。ax (Axes): 当前的 Axes 实例。