Skip to main content

Tool to plot modality vector diagrams

Project description

DiaModality - The Modality Diagram

Simple tool to plot vector modality diagram

pypi_version GitHub Release PyPI - License Python PyPI - Downloads

To install package run the command:

pip install diamodality

Example use case:

See the /demo directory on Git repo or
create and run the following two files:
(file names don't matter)


generate_sample_data.py:

import csv
import random
import os

num_rows = 1500
output_file = 'modality_data.csv'

# locate working directory
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, output_file)

# Open a new CSV file to write the data
with open(file_path, mode='w', newline='') as file:
    writer = csv.writer(file)

    # Generate the data
    signal_treshold = 1.5
    for _ in range(num_rows):

        # generate data columns:
        col1 = random.uniform(0, 2.7)
        col2 = random.uniform(0, 3.3)
        col3 = random.uniform(0, 7.3)

        # generate binarization columns:
        col4 = 1 if col1 > signal_treshold else ''
        col5 = 1 if col2 > signal_treshold else ''
        col6 = 1 if col3 > signal_treshold else ''

        writer.writerow([col1, col2, col3, col4, col5, col6])

plot_sample_data.py:

import DiaModality.ModalityPlot as plt
import scsv as csv
import os

# input files:
files = ['modality_data.csv']

# Get full path
script_dir = os.path.dirname(os.path.realpath(__file__))

for file in files:

    # Get full path of input files
    file_path = os.path.join(script_dir, file)

    # Parse data from csv file
    new_csv = csv.OpenFile(file_path)
    data, binarization = new_csv.GetRows(3, 3)

    # Make figure:
    plot = plt.ModalityPlot(
        data,
        binarization,
        modalities=['Set 1', 'Set 2', 'Set 3'],
        angles=[210, 90, 330],
        labels=False,
        scalecircle=0.5,           # Scale circle radius
        scalecircle_linestyle=':',
        scalecircle_linewidth=0.75,
        marker='',                 # vector endpoints marker
        linestyle='-',
        linewidth=0.5,
        alpha=0.5,
        same_scale=False,          # Draw all the subplots in the same scale
        full_center=True,          # Draw all vectors in the central subplot,
                                   # else draw trimodal vectors only
        whole_sum=True,            # Calculate all three modality vectors despite binarization
        figsize=(10, 10),
        dpi=100,
        title='Modality Diagram Example',
        colors=(
            'tab:green',   # Set 1 color
            'navy',        # Set 2 color
            'tab:red',     # Set 3 color
            '#1E88E5',     # Sets 1 & 2 intersection color
            '#FF9933',     # Sets 1 & 3 intersection color
            '#9900FF',     # Sets 2 & 3 intersection color
            'black',       # All sets   intersection color
        ),      
    )

    plot.save(file_path, type='png', transparent=False)
    plot.show()

Source page: https://github.com/konung-yaropolk/DiaModality

modality_data csv

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

diamodality-0.2.7.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

diamodality-0.2.7-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file diamodality-0.2.7.tar.gz.

File metadata

  • Download URL: diamodality-0.2.7.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for diamodality-0.2.7.tar.gz
Algorithm Hash digest
SHA256 935decbcb7924856fa548e55845a5dc348bf87978f58700f4df5273ad005b9c8
MD5 40bf2bdd15b2717a4314185b36a2f04a
BLAKE2b-256 481e1b6c94ab608672f76d2ea6301bcec607aea912a592b1fe050b8075c1a21c

See more details on using hashes here.

Provenance

The following attestation bundles were made for diamodality-0.2.7.tar.gz:

Publisher: python-publish.yml on konung-yaropolk/DiaModality

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diamodality-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: diamodality-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for diamodality-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6eb950666516524cd209479b0ed97bd973ecf94ab47d3677176368c610d0543a
MD5 1742fb468f4eeae0d2b0bca5d6ab2f90
BLAKE2b-256 dc6f205bd604d1bdeb07386773ace47fc0ded1b167bcbd64a3b6acf2c22abc0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for diamodality-0.2.7-py3-none-any.whl:

Publisher: python-publish.yml on konung-yaropolk/DiaModality

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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