{"id":15693237,"url":"https://github.com/lucacappelletti94/barplots","last_synced_at":"2026-02-21T20:02:45.727Z","repository":{"id":39985613,"uuid":"220299631","full_name":"LucaCappelletti94/barplots","owner":"LucaCappelletti94","description":"Python package to easily make barplots from multi-indexed dataframes.","archived":false,"fork":false,"pushed_at":"2024-10-28T15:34:33.000Z","size":99807,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T03:21:04.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucaCappelletti94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"LucaCappelletti94"}},"created_at":"2019-11-07T18:07:43.000Z","updated_at":"2024-10-28T15:34:37.000Z","dependencies_parsed_at":"2024-10-28T15:52:16.983Z","dependency_job_id":null,"html_url":"https://github.com/LucaCappelletti94/barplots","commit_stats":{"total_commits":273,"total_committers":2,"mean_commits":136.5,"dds":0.00366300366300365,"last_synced_commit":"3dab1a1e9b776c9254c83e300e17a528c7e084ca"},"previous_names":["lucacappelletti94/histograms"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fbarplots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fbarplots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fbarplots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fbarplots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaCappelletti94","download_url":"https://codeload.github.com/LucaCappelletti94/barplots/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252582242,"owners_count":21771634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T18:42:21.748Z","updated_at":"2026-02-21T20:02:45.658Z","avatar_url":"https://github.com/LucaCappelletti94.png","language":"Python","readme":"# Barplots\n\n[![pip](https://badge.fury.io/py/barplots.svg)](https://pypi.org/project/barplots/)\n[![downloads](https://pepy.tech/badge/barplots)](https://pepy.tech/project/barplots)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/LucaCappelletti94/barplots/blob/master/LICENSE)\n[![CI](https://github.com/LucaCappelletti94/barplots/actions/workflows/python.yml/badge.svg)](https://github.com/LucaCappelletti94/barplots/actions)\n\nPython package to easily make barplots from multi-indexed dataframes.\n\n## How do I install this package?\n\nAs usual, just download it using pip:\n\n```shell\npip install barplots\n```\n\n## Documentation\n\nMost methods, in particular those exposed to user usage, are provided with docstrings. Consider reading these docstrings to learn about the most recent updates to the library.\n\n## Examples of the DataFrame structure\n\nThe dataframe to be provided to the barplots library may look like the following:\n\n| miss_rate  | fall_out | mcc       | evaluation_type | unbalance | graph_name                 | normalization_name |\n|------------|----------|-----------|-----------------|-----------|----------------------------|--------------------|\n| 0.0332031  | 0.705078 | 0.353357  | train           | 10        | AlligatorSinensis           | Traditional        |\n| 0.240234   | 0.478516 | 0.289591  | train           | 1         | CanisLupus                  | Right Laplacian     |\n| 0.0253906  | 0.931641 | 0.101643  | train           | 100       | AlligatorSinensis           | Right Laplacian     |\n| 0.121094   | 0.699219 | 0.220219  | train           | 10        | HomoSapiens                 | Traditional        |\n| 0.0136719  | 0.292969 | 0.722095  | test            | 1         | CanisLupus                  | Right Laplacian     |\n| 0.0605469  | 0.90625  | 0.0622185 | test            | 10        | AmanitaMuscariaKoideBx008    | Traditional        |\n| 0.0078125  | 0.4375   | 0.614287  | train           | 100       | AmanitaMuscariaKoideBx008    | Traditional        |\n| 0.171875   | 0.869141 | -0.0572194| train           | 100       | AlligatorSinensis           | Traditional        |\n| 0.0859375  | 0.810547 | 0.150206  | train           | 10        | MusMusculus                 | Right Laplacian     |\n| 0.0273438  | 0.646484 | 0.415357  | test            | 10        | MusMusculus                 | Right Laplacian     |\n\nSpecifically, in this example, we may create bar plots for the features **Miss rate**, **fallout**, and **Matthew Correlation Coefficient** by grouping on the `evaluation_type`, `unbalance`, `graph_name`, and `normalization_name` columns.\n\nAn example CSV file can be seen [here](https://github.com/LucaCappelletti94/barplots/blob/master/tests/test_case.csv).\n\n## Usage examples\n\nHere follows a set of examples of common usages. Basically, every graph shows either the same data or a mean based on the provided group by indices. Choose whatever representation is best for visualizing your data, as one is not necessarily better than another for every dataset.\n\n\u003e **Note**: The data used in the following examples are **randomly generated** for testing purposes. **DO NOT** consider these values as valid results for experiments using the same labels (cell lines, etc.), which are only used to show possible usages.\n\nFor every example, the considered dataframe `df` is loaded as follows:\n\n```python\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\n```\n\nAlso, for every example, the `custom_defaults` used to sanitize the labels specific to the dataset is:\n\n```python\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n```\n\n### Horizontal Example A\n\nIn the following example, we will plot the bars horizontally, rotating the group labels by 90 degrees, and displaying the bar labels as a shared legend.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"task\", \"model\"],\n    orientation=\"horizontal\",\n    show_legend=True,\n    minor_rotation=90,\n    custom_defaults=custom_defaults\n)\n```\n\nResult can be seen [here](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/horizontal_legend_minor_rotation_val_auroc.png?raw=true).\n\n### Horizontal Example B\n\nIn this example, we will plot the top index as multiple subplots with horizontal bars, rotating the group labels by 90 degrees, and displaying the bar labels as a shared legend.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"cell_line\", \"task\", \"model\"],\n    orientation=\"horizontal\",\n    show_legend=True,\n    subplots=True,\n    minor_rotation=90,\n    custom_defaults=custom_defaults\n)\n```\n\n![Horizontal Example B](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/horizontal_legend_subplots_minor_rotation_val_auroc.png?raw=true)\n\n### Horizontal Example C\n\nIn this example, we will plot horizontal bars, rotating the top group labels by 90 degrees, and displaying the bar labels as minor ticks.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"task\", \"model\"],\n    orientation=\"horizontal\",\n    show_legend=False,\n    major_rotation=90,\n    custom_defaults=custom_defaults\n)\n```\n\nResult can be seen [here](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/horizontal_major_rotation_val_auroc.png?raw=true).\n\n### Horizontal Example D\n\nIn this example, we will plot the top index as multiple subplots with horizontal bars, rotating the group labels by 90 degrees, and displaying the bar labels as minor ticks.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"cell_line\", \"task\", \"model\"],\n    orientation=\"horizontal\",\n    show_legend=False,\n    major_rotation=90,\n    subplots=True,\n    custom_defaults=custom_defaults\n)\n```\n\n![Horizontal Example D](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/horizontal_subplots_major_rotation_val_auroc.png?raw=true)\n\n### Vertical Example A\n\nIn this example, we will plot the bars vertically and display the bar labels as a shared legend.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"task\", \"model\"],\n    orientation=\"vertical\",\n    show_legend=True,\n    custom_defaults=custom_defaults\n)\n```\n\nResult can be seen [here](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/vertical_legend_val_auroc.png).\n\n### Vertical Example B\n\nIn this example, we will plot the top index as multiple subplots with vertical bars, displaying the bar labels as a shared legend.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"cell_line\", \"task\", \"model\"],\n    orientation=\"vertical\",\n    show_legend=True,\n    subplots=True,\n    custom_defaults=custom_defaults\n)\n```\n\n![Vertical Example B](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/vertical_legend_subplots_val_auroc.png)\n\n### Vertical Example C\n\nIn this example, we will plot vertical bars, rotating the minor group labels by 90 degrees, and displaying the bar labels as minor ticks.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"task\", \"model\"],\n    orientation=\"vertical\",\n    show_legend=False,\n    minor_rotation=90,\n    custom_defaults=custom_defaults\n)\n```\n\nResult can be seen [here](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/vertical_minor_rotation_val_auroc.png).\n\n### Vertical Example D\n\nIn this example, we will plot the top index as multiple subplots with vertical bars, rotating the minor group labels by 90 degrees, and displaying the bar labels as minor ticks.\n\n```python\nfrom barplots import barplots\nimport pandas as pd\n\ndf = pd.read_csv(\"tests/test_case.csv\")\ncustom_defaults = {\n    \"P\": \"promoters\",\n    \"E\": \"enhancers\",\n    \"A\": \"active \",\n    \"I\": \"inactive \",\n    \"+\": \" and \",\n    \"\": \"anything\",\n    \"Validation\": \"val\"\n}\n\nbarplots(\n    df,\n    groupby=[\"cell_line\", \"task\", \"model\"],\n    orientation=\"vertical\",\n    show_legend=False,\n    minor_rotation=90,\n    subplots=True,\n    custom_defaults=custom_defaults\n)\n```\n\n![Vertical Example D](https://github.com/LucaCappelletti94/barplots/blob/master/examples/1/vertical_subplots_minor_rotation_val_auroc.png)\n","funding_links":["https://github.com/sponsors/LucaCappelletti94"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fbarplots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucacappelletti94%2Fbarplots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fbarplots/lists"}