Skip to main content

Visualize statistical significance on existing Matplotlib plots by adding

Project description

✨ starbars ✨

This Python tool helps visualizing statistical significance on existing Matplotlib plots by adding significance bars and p-value labels between chosen pairs of columns.

Example plot

Features

  • Converts p-values to asterisk notations for easy interpretation.
  • Draws statistical significance bars on Matplotlib plots.
  • Customizable bar margins, tip lengths, font sizes, and top margins.

Installation

You can install the package via pip:

pip install starbars

Example

import starbars
import matplotlib.pyplot as plt

# Example data
categories = ['A', 'B', 'C']
values = [10, 20, 15]
annotations = [('A', 'B', 0.01), ('B', 'C', 0.05)]
plt.bar(categories, values)

# Annotate significance
starbars.draw_annotation(annotations)

plt.show()

This example creates a simple bar plot and uses the draw_annotation function to add statistical significance annotations between the specified pairs. For more detailed examples, please check the example.

Parameters

  • annotations: List of tuples (x1, x2, p) containing the x-axis labels and the p-value of the pair.
  • ns_show: Whether to show bars for non-statistical p-values. (Default: True)
  • ax: The axis of subplots to draw annotations on. If ax is not provided, it implies that you are working with a single plot rather than a set of subplots. In such cases, the annotations apply to the only existing plot in the figure. (Default: None)
  • bar_gap: Gap in between the bars of data. Default is 3% of the y-axis.
  • tip_length: Length of the tip of the statistical bar. Default is 3% of the y-axis.
  • top_margin: Margin of the last annotation from the top of the graph. Default is 5% of the y-axis.
  • text_distance: Distance between the bar and the text. Default is 2% of the y-axis.
  • fontsize: Font size of the annotations. Default is 10.

Contributing

We welcome contributions! If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

To contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature-branch)
  5. Open a pull request

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starbars-3.1.0.tar.gz (190.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starbars-3.1.0-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file starbars-3.1.0.tar.gz.

File metadata

  • Download URL: starbars-3.1.0.tar.gz
  • Upload date:
  • Size: 190.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for starbars-3.1.0.tar.gz
Algorithm Hash digest
SHA256 d82ed9965c167f4724a63b7625bc904f7a36262bc9e6490a1976f98b69d998e1
MD5 4cb9ad625fc86b856d40d2fd22c421a2
BLAKE2b-256 7bf3985239c8f170c3438a2908825af32bad2ceff3549866cf73bee28f34fc5d

See more details on using hashes here.

File details

Details for the file starbars-3.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: starbars-3.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for starbars-3.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1c7f8c84972544418f9f7bbb8cf9646751acdb1327854359d6f2d21fb5ef8942
MD5 ef6712974db5c76d43742951d9022f35
BLAKE2b-256 6a833ba038ab66a565ae89e9a6d63fd1b78694aa5a5f1c1338857188e7c5bd8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page