Tool to plot modality vector diagrams
Project description
DiaModality - The Modality Diagram
Simple tool to plot vector modality diagram
To install package run the command:
pip install diamodality
Example of use:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file diamodality-0.2.3.tar.gz
.
File metadata
- Download URL: diamodality-0.2.3.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca747df8a152a9d40d925babd86cdb98aadb6ce6ab93bd84753565b669839431 |
|
MD5 | f3046ba17da3b442554fddde5f427b4f |
|
BLAKE2b-256 | 83ada3524799fb03b0da3fc1e11ecbd2cc73ee8dd447031c8ab52d37ff1207af |
Provenance
The following attestation bundles were made for diamodality-0.2.3.tar.gz
:
Publisher:
python-publish.yml
on konung-yaropolk/DiaModality
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
diamodality-0.2.3.tar.gz
- Subject digest:
ca747df8a152a9d40d925babd86cdb98aadb6ce6ab93bd84753565b669839431
- Sigstore transparency entry: 158464763
- Sigstore integration time:
- Permalink:
konung-yaropolk/DiaModality@8525cf046b2f5f24790da335923a53b2d6917ef2
- Branch / Tag:
refs/tags/v0.2.3
- Owner: https://github.com/konung-yaropolk
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@8525cf046b2f5f24790da335923a53b2d6917ef2
- Trigger Event:
release
- Statement type:
File details
Details for the file DiaModality-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: DiaModality-0.2.3-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c11441c45bab8520b5ae97ae84705103dbf2e23dd05069e1c49d5760f8ec8c4 |
|
MD5 | c0ab49e74f733df84845fc2c616aa5a0 |
|
BLAKE2b-256 | cdf0816b9cd11cc6fe6b4693bdc6fb9ed72c91fad15f99bcd9ca449ab77c34e3 |
Provenance
The following attestation bundles were made for DiaModality-0.2.3-py3-none-any.whl
:
Publisher:
python-publish.yml
on konung-yaropolk/DiaModality
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
diamodality-0.2.3-py3-none-any.whl
- Subject digest:
1c11441c45bab8520b5ae97ae84705103dbf2e23dd05069e1c49d5760f8ec8c4
- Sigstore transparency entry: 158464764
- Sigstore integration time:
- Permalink:
konung-yaropolk/DiaModality@8525cf046b2f5f24790da335923a53b2d6917ef2
- Branch / Tag:
refs/tags/v0.2.3
- Owner: https://github.com/konung-yaropolk
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@8525cf046b2f5f24790da335923a53b2d6917ef2
- Trigger Event:
release
- Statement type: