Python包,可以轻松地从多索引数据帧生成条形图。
barplots的Python项目详细描述
Python包可以轻松地从多索引数据帧生成条形图。在
如何安装此软件包?在
像往常一样,只需使用pip下载:
pip install barplots
文件
大多数方法,特别是那些公开给用户使用的方法,都提供了doc字符串。 考虑阅读这些docstring以了解库的最新更新。在
使用示例
下面是一组常见用法的示例。基本上,每一个图表都显示相同的数据 或基于提供的分组指数的平均值。选择哪个代表最适合 可视化您的数据,因为几乎没有一个比另一个更好的每个可能的数据集。在
注意:以下示例中使用的数据是随机生成的,因此对测试项目非常有用。 不要将这些值视为使用相同标签(细胞系等)的有效结果 只用于显示可能的用法。在
对于每个示例,考虑的数据帧df
的加载如下:
另外,对于每个示例,用于清理特定于所用数据集的标签的custom_defaults
是:
custom_defaults={"P":"promoters","E":"enhancers","A":"active ","I":"inactive ","+":" and ","":"anything","Validation":"val"}
水平示例A
在下面的示例中,我们将水平地绘制条形图,将组标签旋转90度 将条形标签显示为共享图例。在
frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="horizontal",show_legend=True,minor_rotation=90,custom_defaults=custom_defaults)
结果可以看到here。在
水平示例B
在下面的示例中,我们将顶部索引绘制为多个 带有水平条的子图,将组标签旋转90度并 将条形标签显示为共享图例。在
frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="horizontal",show_legend=True,subplots=True,minor_rotation=90,custom_defaults=custom_defaults)^{1}$
水平示例C
在下面的例子中,我们将以水平和旋转90度的方式绘制下面的标签 将条形标签显示为小刻度。在
frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="horizontal",show_legend=False,major_rotation=90,custom_defaults=custom_defaults)
结果可见here
水平示例D
在下面的示例中,我们将顶部索引绘制为多个 带有水平条的子图,将组标签旋转90度并 将条形标签显示为小刻度。在
frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="horizontal",show_legend=False,major_rotation=90,subplots=True,custom_defaults=custom_defaults)
垂直示例A
在下面的示例中,我们将垂直绘制条形图 将条形标签显示为共享图例。在
frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="vertical",show_legend=True,custom_defaults=custom_defaults)
结果可见here
垂直示例B
在下面的示例中,我们将顶部索引绘制为多个 带有垂直条并将条形标签显示为共享图例的子批次。在
frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="vertical",show_legend=True,subplots=True,custom_defaults=custom_defaults)
垂直示例C
在下面的示例中,我们将绘制垂直条,将次要组标签旋转90度并 将条形标签显示为小刻度。在
frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="vertical",show_legend=False,minor_rotation=90,custom_defaults=custom_defaults)
结果可见here
垂直示例D
在下面的示例中,我们将顶部索引绘制为多个 带有垂直条的子图,将次要组标签旋转90度并 将条形标签显示为小刻度。在
frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="vertical",show_legend=False,minor_rotation=90,subplots=True,custom_defaults=custom_defaults)
未来特色
目前无法自动检测标签重叠和旋转。
当我有时间的时候,我将使用这个特性,目前您需要使用参数minor_rotation
和{
- 项目
标签: