DiaModality


NameDiaModality JSON
Version 0.1.7 PyPI version JSON
download
home_pageNone
SummaryTool to plot modality vector diagrams
upload_time2024-12-06 01:07:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2024 konung-yaropolk 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 visualization plotting matplotlib
VCS
bugtrack_url
requirements matplotlib numpy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DiaModality - The Modality Diagram

Simple tool to plot vector modality diagram  

[![pypi_version](https://img.shields.io/pypi/v/diamodality?label=PyPI&color=green)](https://pypi.org/project/diamodality)
[![PyPI - License](https://img.shields.io/pypi/l/diamodality)](https://pypi.org/project/diamodality)
[![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/diamodality)  


### To install package run the command:
```bash
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``:
```python
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``:
```python
import DiaModality.CsvParser as csv
import DiaModality.ModalityPlot as plt
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.LoadCsv(file_path)
    data, binarization = new_csv.ParseCsv(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),
        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](https://github.com/user-attachments/assets/eb77b4d7-281f-45b0-a5ce-4c2442fc9a75)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "DiaModality",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "Visualization, Plotting, Matplotlib",
    "author": null,
    "author_email": "konung-yaropolk <yaropolk1995@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5c/c6/0232b118bf13e3ac3cef7863a2cdf6295870946634bdb2c1e8c642c88267/diamodality-0.1.7.tar.gz",
    "platform": null,
    "description": "# DiaModality - The Modality Diagram\n\nSimple tool to plot vector modality diagram  \n\n[![pypi_version](https://img.shields.io/pypi/v/diamodality?label=PyPI&color=green)](https://pypi.org/project/diamodality)\n[![PyPI - License](https://img.shields.io/pypi/l/diamodality)](https://pypi.org/project/diamodality)\n[![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/diamodality)  \n\n\n### To install package run the command:\n```bash\npip install diamodality\n```\n\n\n### Example of use:\nSee the /demo directory on Git repo or  \ncreate and run the following two files:  \n*(file names don't matter)*\n\n---\n``generate_sample_data.py``:\n```python\nimport csv\nimport random\nimport os\n\nnum_rows = 1500\noutput_file = 'modality_data.csv'\n\n# locate working directory\nscript_dir = os.path.dirname(os.path.realpath(__file__))\nfile_path = os.path.join(script_dir, output_file)\n\n# Open a new CSV file to write the data\nwith open(file_path, mode='w', newline='') as file:\n    writer = csv.writer(file)\n\n    # Generate the data\n    signal_treshold = 1.5\n    for _ in range(num_rows):\n\n        # generate data columns:\n        col1 = random.uniform(0, 2.7)\n        col2 = random.uniform(0, 3.3)\n        col3 = random.uniform(0, 7.3)\n\n        # generate binarization columns:\n        col4 = 1 if col1 > signal_treshold else ''\n        col5 = 1 if col2 > signal_treshold else ''\n        col6 = 1 if col3 > signal_treshold else ''\n\n        writer.writerow([col1, col2, col3, col4, col5, col6])\n\n```\n\n\n---\n``plot_sample_data.py``:\n```python\nimport DiaModality.CsvParser as csv\nimport DiaModality.ModalityPlot as plt\nimport os\n\n# input files:\nfiles = ['modality_data.csv']\n\n# Get full path\nscript_dir = os.path.dirname(os.path.realpath(__file__))\n\nfor file in files:\n\n    # Get full path of input files\n    file_path = os.path.join(script_dir, file)\n\n    # Parse data from csv file\n    new_csv = csv.LoadCsv(file_path)\n    data, binarization = new_csv.ParseCsv(3, 3)\n\n    # Make figure:\n    plot = plt.ModalityPlot(\n        data,\n        binarization,\n        modalities=['Set 1', 'Set 2', 'Set 3'],\n        angles=[210, 90, 330],\n        labels=False,\n        scalecircle=0.5,           # Scale circle radius\n        scalecircle_linestyle=':',\n        scalecircle_linewidth=0.75,\n        marker='',                 # vector endpoints marker\n        linestyle='-',\n        linewidth=0.5,\n        alpha=0.5,\n        same_scale=False,          # Draw all the subplots in the same scale\n        full_center=True,          # Draw all vectors in the central subplot,\n                                   # else draw trimodal vectors only\n        whole_sum=True,            # Calculate all three modality vectors despite binarization\n        figsize=(10, 10),\n        title='Modality Diagram Example',\n        colors=(\n            'tab:green',   # Set 1 color\n            'navy',        # Set 2 color\n            'tab:red',     # Set 3 color\n            '#1E88E5',     # Sets 1 & 2 intersection color\n            '#FF9933',     # Sets 1 & 3 intersection color\n            '#9900FF',     # Sets 2 & 3 intersection color\n            'black',       # All sets   intersection color\n        ),      \n    )\n\n    plot.save(file_path, type='png', transparent=False)\n    plot.show()\n```\n\nSource page: \nhttps://github.com/konung-yaropolk/DiaModality\n\n\n![modality_data csv](https://github.com/user-attachments/assets/eb77b4d7-281f-45b0-a5ce-4c2442fc9a75)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 konung-yaropolk  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.",
    "summary": "Tool to plot modality vector diagrams",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/konung-yaropolk/DiaModality",
        "Issues": "https://github.com/konung-yaropolk/DiaModality/issues"
    },
    "split_keywords": [
        "visualization",
        " plotting",
        " matplotlib"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31b0cf573961b7826b57afea8e66638fa3c1ef331d5cb1caae1671a1257c3a69",
                "md5": "14f152de9cfd78b4d9a8c7e530b1bdfa",
                "sha256": "01c6ab575eb00e715fc65351144db5c85ea9c86b029c73cbad5af6a5729fc33f"
            },
            "downloads": -1,
            "filename": "DiaModality-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "14f152de9cfd78b4d9a8c7e530b1bdfa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9162,
            "upload_time": "2024-12-06T01:07:20",
            "upload_time_iso_8601": "2024-12-06T01:07:20.761089Z",
            "url": "https://files.pythonhosted.org/packages/31/b0/cf573961b7826b57afea8e66638fa3c1ef331d5cb1caae1671a1257c3a69/DiaModality-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5cc60232b118bf13e3ac3cef7863a2cdf6295870946634bdb2c1e8c642c88267",
                "md5": "2bce8d94f57c64a63e68392f5369c5e3",
                "sha256": "b6d1c768bbde438cf1afde9c4433bbf77281b1c46f9d6e31d6d144bf8188b549"
            },
            "downloads": -1,
            "filename": "diamodality-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "2bce8d94f57c64a63e68392f5369c5e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9721,
            "upload_time": "2024-12-06T01:07:22",
            "upload_time_iso_8601": "2024-12-06T01:07:22.505277Z",
            "url": "https://files.pythonhosted.org/packages/5c/c6/0232b118bf13e3ac3cef7863a2cdf6295870946634bdb2c1e8c642c88267/diamodality-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-06 01:07:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "konung-yaropolk",
    "github_project": "DiaModality",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        }
    ],
    "lcname": "diamodality"
}
        
Elapsed time: 0.48511s