ggpubpy


Nameggpubpy JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
Summarymatplotlib Based Publication-Ready Plots with Statistical Tests
upload_time2025-09-04 02:04:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 Izzet Turkalp Akbasli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords matplotlib plotting visualization statistics publication ggplot data-science alluvial flow-diagram correlation-matrix boxplot violin-plot shift-plot
VCS
bugtrack_url
requirements numpy pandas matplotlib scipy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ggpubpy

[![Documentation Status](https://readthedocs.org/projects/ggpubpy/badge/?version=latest)](https://ggpubpy.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/ggpubpy.svg)](https://badge.fury.io/py/ggpubpy)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**ggpubpy** is a Python library for creating publication-ready plots with built-in statistical tests and automatic p-value annotations. Inspired by R's ggpubr package, ggpubpy provides easy-to-use functions for creating professional visualizations suitable for scientific publications.

## Features

- 📊 **Publication-ready plots**: Clean, professional appearance suitable for scientific publications
- 🔬 **Built-in statistical tests**: Automatic ANOVA, t-tests, correlation analysis, and more
- ⭐ **Automatic annotations**: P-values and significance stars added automatically
- 🎨 **Flexible customization**: Extensive options for colors, styling, and layout
- 📈 **Multiple plot types**: Box plots, violin plots, correlation matrices, shift plots, and alluvial plots
- 🔗 **Easy integration**: Works seamlessly with pandas DataFrames and numpy arrays

## Installation

```bash
pip install ggpubpy
```

## Quick Start

```python
from ggpubpy import plot_boxplot_with_stats, load_iris
import matplotlib.pyplot as plt

# Load sample data
iris = load_iris()

# Create a publication-ready boxplot with statistical annotations
fig, ax = plot_boxplot_with_stats(
    df=iris,
    x="species",
    y="sepal_length",
    title="Sepal Length by Species"
)

plt.show()
```

## Available Plot Types

### 📊 Box Plots
Create box plots with statistical annotations including ANOVA/Kruskal-Wallis tests and pairwise comparisons.

```python
from ggpubpy import plot_boxplot_with_stats, load_iris

fig, ax = plot_boxplot_with_stats(
    df=load_iris(),
    x="species",
    y="sepal_length",
    parametric=False  # Use non-parametric tests
)
```

### 🎻 Violin Plots
Visualize data distributions with violin plots that combine the benefits of box plots and density plots.

```python
from ggpubpy import plot_violin_with_stats, load_iris

fig, ax = plot_violin_with_stats(
    df=load_iris(),
    x="species",
    y="petal_length",
    palette={"setosa": "#FF6B6B", "versicolor": "#4ECDC4", "virginica": "#45B7D1"}
)
```

### 📈 Shift Plots
Perfect for before-after comparisons and paired data analysis.

```python
from ggpubpy import plot_shift
import numpy as np

# Create sample paired data
before = np.random.normal(10, 2, 30)
after = before + np.random.normal(1, 1.5, 30)

fig, ax = plot_shift(
    x=before,
    y=after,
    x_label="Before Treatment",
    y_label="After Treatment"
)
```

### 🔗 Correlation Matrix
Comprehensive visualization of relationships between multiple variables.

```python
from ggpubpy import plot_correlation_matrix, load_iris

fig, ax = plot_correlation_matrix(
    df=load_iris(),
    columns=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'],
    title="Iris Dataset Correlation Matrix"
)
```

### 🌊 Alluvial Plots
Flow diagrams showing how data moves between categorical dimensions.

```python
from ggpubpy import plot_alluvial, load_titanic
import pandas as pd
import numpy as np

# Load and prepare data
titanic = load_titanic()
titanic = titanic.dropna(subset=["Age"])
titanic["Class"] = titanic["Pclass"].map({1: "1st", 2: "2nd", 3: "3rd"})
titanic["AgeCat"] = np.where(titanic["Age"] < 18, "Child", "Adult")
titanic["Survived"] = titanic["Survived"].astype(str).replace({"0": "No", "1": "Yes"})

# Create frequency table
titanic_tab = (titanic.groupby(["Class", "Sex", "AgeCat", "Survived"])
                    .size()
                    .reset_index(name="Freq")
                    .rename(columns={"AgeCat": "Age"}))
titanic_tab["alluvium"] = titanic_tab.index

# Create alluvial plot
fig, ax = plot_alluvial(
    titanic_tab,
    dims=["Class", "Sex", "Age"],
    value_col="Freq",
    color_by="Survived",
    id_col="alluvium",
    title="Titanic Survival Analysis"
)
```

## Statistical Tests

ggpubpy automatically performs appropriate statistical tests:

- **Global Tests**: One-way ANOVA, Kruskal-Wallis
- **Pairwise Comparisons**: t-tests, Mann-Whitney U tests
- **Correlation Analysis**: Pearson, Spearman, Kendall
- **Significance Levels**: `***` p < 0.001, `**` p < 0.01, `*` p < 0.05, `ns` p ≥ 0.05

## Documentation

📖 **Complete documentation** is available at [https://ggpubpy.readthedocs.io](https://ggpubpy.readthedocs.io)

The documentation includes:
- Detailed function references
- Comprehensive examples
- Statistical test explanations
- Customization guides
- Best practices

## Examples

Check out the `examples/` directory for complete working examples:

- `basic_usage.py`: Introduction to ggpubpy functions
- `alluvial_examples.py`: Alluvial plot examples
- `correlation_matrix_example.py`: Correlation matrix examples

## Dependencies

- Python 3.8+
- matplotlib
- pandas
- numpy
- scipy (for statistical tests)

## Contributing

We welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for more information.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Citation

If you use ggpubpy in your research, please cite:

```bibtex
@software{ggpubpy,
  title={ggpubpy: Publication-Ready Plots for Python},
  author={Izzet Turkalp Akbasli},
  year={2024},
  url={https://github.com/yourusername/ggpubpy}
}
```

## Support

For questions, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/yourusername/ggpubpy).

---

**Happy plotting! 📊✨**

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ggpubpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Turkalp Akbasli <akbaslint@gmail.com>",
    "keywords": "matplotlib, plotting, visualization, statistics, publication, ggplot, data-science, alluvial, flow-diagram, correlation-matrix, boxplot, violin-plot, shift-plot",
    "author": null,
    "author_email": "Turkalp Akbasli <akbaslint@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/cb/f448d0d64d26fe6af927890117e874c95447185683f5ad0a4ba56ec07bf4/ggpubpy-0.4.1.tar.gz",
    "platform": null,
    "description": "# ggpubpy\n\n[![Documentation Status](https://readthedocs.org/projects/ggpubpy/badge/?version=latest)](https://ggpubpy.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/ggpubpy.svg)](https://badge.fury.io/py/ggpubpy)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**ggpubpy** is a Python library for creating publication-ready plots with built-in statistical tests and automatic p-value annotations. Inspired by R's ggpubr package, ggpubpy provides easy-to-use functions for creating professional visualizations suitable for scientific publications.\n\n## Features\n\n- \ud83d\udcca **Publication-ready plots**: Clean, professional appearance suitable for scientific publications\n- \ud83d\udd2c **Built-in statistical tests**: Automatic ANOVA, t-tests, correlation analysis, and more\n- \u2b50 **Automatic annotations**: P-values and significance stars added automatically\n- \ud83c\udfa8 **Flexible customization**: Extensive options for colors, styling, and layout\n- \ud83d\udcc8 **Multiple plot types**: Box plots, violin plots, correlation matrices, shift plots, and alluvial plots\n- \ud83d\udd17 **Easy integration**: Works seamlessly with pandas DataFrames and numpy arrays\n\n## Installation\n\n```bash\npip install ggpubpy\n```\n\n## Quick Start\n\n```python\nfrom ggpubpy import plot_boxplot_with_stats, load_iris\nimport matplotlib.pyplot as plt\n\n# Load sample data\niris = load_iris()\n\n# Create a publication-ready boxplot with statistical annotations\nfig, ax = plot_boxplot_with_stats(\n    df=iris,\n    x=\"species\",\n    y=\"sepal_length\",\n    title=\"Sepal Length by Species\"\n)\n\nplt.show()\n```\n\n## Available Plot Types\n\n### \ud83d\udcca Box Plots\nCreate box plots with statistical annotations including ANOVA/Kruskal-Wallis tests and pairwise comparisons.\n\n```python\nfrom ggpubpy import plot_boxplot_with_stats, load_iris\n\nfig, ax = plot_boxplot_with_stats(\n    df=load_iris(),\n    x=\"species\",\n    y=\"sepal_length\",\n    parametric=False  # Use non-parametric tests\n)\n```\n\n### \ud83c\udfbb Violin Plots\nVisualize data distributions with violin plots that combine the benefits of box plots and density plots.\n\n```python\nfrom ggpubpy import plot_violin_with_stats, load_iris\n\nfig, ax = plot_violin_with_stats(\n    df=load_iris(),\n    x=\"species\",\n    y=\"petal_length\",\n    palette={\"setosa\": \"#FF6B6B\", \"versicolor\": \"#4ECDC4\", \"virginica\": \"#45B7D1\"}\n)\n```\n\n### \ud83d\udcc8 Shift Plots\nPerfect for before-after comparisons and paired data analysis.\n\n```python\nfrom ggpubpy import plot_shift\nimport numpy as np\n\n# Create sample paired data\nbefore = np.random.normal(10, 2, 30)\nafter = before + np.random.normal(1, 1.5, 30)\n\nfig, ax = plot_shift(\n    x=before,\n    y=after,\n    x_label=\"Before Treatment\",\n    y_label=\"After Treatment\"\n)\n```\n\n### \ud83d\udd17 Correlation Matrix\nComprehensive visualization of relationships between multiple variables.\n\n```python\nfrom ggpubpy import plot_correlation_matrix, load_iris\n\nfig, ax = plot_correlation_matrix(\n    df=load_iris(),\n    columns=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'],\n    title=\"Iris Dataset Correlation Matrix\"\n)\n```\n\n### \ud83c\udf0a Alluvial Plots\nFlow diagrams showing how data moves between categorical dimensions.\n\n```python\nfrom ggpubpy import plot_alluvial, load_titanic\nimport pandas as pd\nimport numpy as np\n\n# Load and prepare data\ntitanic = load_titanic()\ntitanic = titanic.dropna(subset=[\"Age\"])\ntitanic[\"Class\"] = titanic[\"Pclass\"].map({1: \"1st\", 2: \"2nd\", 3: \"3rd\"})\ntitanic[\"AgeCat\"] = np.where(titanic[\"Age\"] < 18, \"Child\", \"Adult\")\ntitanic[\"Survived\"] = titanic[\"Survived\"].astype(str).replace({\"0\": \"No\", \"1\": \"Yes\"})\n\n# Create frequency table\ntitanic_tab = (titanic.groupby([\"Class\", \"Sex\", \"AgeCat\", \"Survived\"])\n                    .size()\n                    .reset_index(name=\"Freq\")\n                    .rename(columns={\"AgeCat\": \"Age\"}))\ntitanic_tab[\"alluvium\"] = titanic_tab.index\n\n# Create alluvial plot\nfig, ax = plot_alluvial(\n    titanic_tab,\n    dims=[\"Class\", \"Sex\", \"Age\"],\n    value_col=\"Freq\",\n    color_by=\"Survived\",\n    id_col=\"alluvium\",\n    title=\"Titanic Survival Analysis\"\n)\n```\n\n## Statistical Tests\n\nggpubpy automatically performs appropriate statistical tests:\n\n- **Global Tests**: One-way ANOVA, Kruskal-Wallis\n- **Pairwise Comparisons**: t-tests, Mann-Whitney U tests\n- **Correlation Analysis**: Pearson, Spearman, Kendall\n- **Significance Levels**: `***` p < 0.001, `**` p < 0.01, `*` p < 0.05, `ns` p \u2265 0.05\n\n## Documentation\n\n\ud83d\udcd6 **Complete documentation** is available at [https://ggpubpy.readthedocs.io](https://ggpubpy.readthedocs.io)\n\nThe documentation includes:\n- Detailed function references\n- Comprehensive examples\n- Statistical test explanations\n- Customization guides\n- Best practices\n\n## Examples\n\nCheck out the `examples/` directory for complete working examples:\n\n- `basic_usage.py`: Introduction to ggpubpy functions\n- `alluvial_examples.py`: Alluvial plot examples\n- `correlation_matrix_example.py`: Correlation matrix examples\n\n## Dependencies\n\n- Python 3.8+\n- matplotlib\n- pandas\n- numpy\n- scipy (for statistical tests)\n\n## Contributing\n\nWe welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for more information.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use ggpubpy in your research, please cite:\n\n```bibtex\n@software{ggpubpy,\n  title={ggpubpy: Publication-Ready Plots for Python},\n  author={Izzet Turkalp Akbasli},\n  year={2024},\n  url={https://github.com/yourusername/ggpubpy}\n}\n```\n\n## Support\n\nFor questions, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/yourusername/ggpubpy).\n\n---\n\n**Happy plotting! \ud83d\udcca\u2728**\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Izzet Turkalp Akbasli\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "matplotlib Based Publication-Ready Plots with Statistical Tests",
    "version": "0.4.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/turkalpmd/ggpubpy/issues",
        "Documentation": "https://ggpubpy.readthedocs.io",
        "Download": "https://pypi.org/project/ggpubpy/#files",
        "Homepage": "https://github.com/turkalpmd/ggpubpy",
        "Repository": "https://github.com/turkalpmd/ggpubpy.git",
        "Source Code": "https://github.com/turkalpmd/ggpubpy"
    },
    "split_keywords": [
        "matplotlib",
        " plotting",
        " visualization",
        " statistics",
        " publication",
        " ggplot",
        " data-science",
        " alluvial",
        " flow-diagram",
        " correlation-matrix",
        " boxplot",
        " violin-plot",
        " shift-plot"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "97ce87b3338add5fd863a4e4dca3beead15739437ed2040f5ef7135ee19582a3",
                "md5": "3203b74be8d7a7caf8578e46764be91e",
                "sha256": "015bee9e6d1592e0f827b4f4a6eee32378d3157f80c83e95fdb3206786e95f87"
            },
            "downloads": -1,
            "filename": "ggpubpy-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3203b74be8d7a7caf8578e46764be91e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 26415,
            "upload_time": "2025-09-04T02:04:02",
            "upload_time_iso_8601": "2025-09-04T02:04:02.096047Z",
            "url": "https://files.pythonhosted.org/packages/97/ce/87b3338add5fd863a4e4dca3beead15739437ed2040f5ef7135ee19582a3/ggpubpy-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "45cbf448d0d64d26fe6af927890117e874c95447185683f5ad0a4ba56ec07bf4",
                "md5": "4ec761f3b6dd0936273bb28d8cd81922",
                "sha256": "34a28cac4d58f3d78facad2908968139b4053dcf1fe7e130485e47139e8e5c99"
            },
            "downloads": -1,
            "filename": "ggpubpy-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4ec761f3b6dd0936273bb28d8cd81922",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 36706,
            "upload_time": "2025-09-04T02:04:03",
            "upload_time_iso_8601": "2025-09-04T02:04:03.015877Z",
            "url": "https://files.pythonhosted.org/packages/45/cb/f448d0d64d26fe6af927890117e874c95447185683f5ad0a4ba56ec07bf4/ggpubpy-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-04 02:04:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "turkalpmd",
    "github_project": "ggpubpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.20.0"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    ">=",
                    "3.5.0"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.7.0"
                ]
            ]
        }
    ],
    "lcname": "ggpubpy"
}
        
Elapsed time: 1.12735s