Skip to main content

A spiral plot generator

Project description

Spiral Plot

A Python package to create scatter plots where each point is represented by a spiral glyph. This is useful for visualizing a third dimension of data (magnitude, duration, etc.) as the complexity or size of a spiral at a specific 2D location. It also supports visualizing two values simultaneously using a dual-colored spiral.

Installation

You can install this package locally using pip:

pip install .

Or directly from GitHub:

pip install git+https://github.com/bioinfoguru/spiralplot.git

Usage

Single Spiral Value

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from spiralplot import spiralplot

# Create sample data
n = 20
df = pd.DataFrame({
    'x_pos': np.random.rand(n) * 100,
    'y_pos': np.random.rand(n) * 100,
    'magnitude': np.random.rand(n) * 50 + 10 
})

plt.figure(figsize=(10, 10))
spiralplot(
    data=df,
    x='x_pos',
    y='y_pos',
    spiral='magnitude',
    cmap='magma',
    scale=0.5,
    dpt=15
)
plt.show()

Dual Spiral Values

You can visualize two values at once. The total length of the spiral represents the sum of the values, and the spiral is split into two colors proportional to each value.

df['magnitude2'] = np.random.rand(n) * 50 + 10

plt.figure(figsize=(10, 10))
spiralplot(
    data=df,
    x='x_pos',
    y='y_pos',
    spiral=['magnitude', 'magnitude2'], # Pass list of two columns
    spiral_colors=['blue', 'red'],      # Colors for each part
    scale=0.5
)
plt.show()

API

spiralplot(data, x, y, spiral, ax=None, cmap='viridis', color=None, scale=1.0, spiral_scale=0.1, spiral_colors=None, dpt=10, **kwargs)

  • data: Input pandas DataFrame.
  • x: Column name for x-axis position.
  • y: Column name for y-axis position.
  • spiral: Column name (str) or list of two column names (list of str).
    • If single string: Maps value to spiral length.
    • If list of two strings: Maps sum of values to length, splits spiral into two colors.
  • ax: Optional matplotlib Axes.
  • cmap: Colormap for the spirals. Ignored if color is provided or if spiral is a list.
  • color: Single color to use for all spirals. Overrides cmap. Ignored if spiral is a list.
  • scale: Global scaling factor for the size of the spirals relative to data coordinates.
  • spiral_scale: Factor to control the size of individual dots within the spiral.
  • spiral_colors: List of two colors (e.g. ['green', 'orange']) to use when spiral is a list of two columns.
  • dpt: Dots per turn. Specifies the number of dots in a turn of the helix. Defaults to 10.
  • **kwargs: Additional arguments passed to plt.scatter.

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

spiralplot-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

spiralplot-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file spiralplot-0.1.1.tar.gz.

File metadata

  • Download URL: spiralplot-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for spiralplot-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a47b37b5f61ab3180ddcd5247d4c27b37013f4314f8910c392af0e66fc5fdc49
MD5 7b522c05de66e1a5a49714a3b8344730
BLAKE2b-256 bca7e792a00e7722dcbb85425508ecc8702f2a852617c6dd461cf81043da1d35

See more details on using hashes here.

File details

Details for the file spiralplot-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spiralplot-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for spiralplot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c970dc520f18294fd0dd10237b7d4393f2b5239efc454170c92f6e7684c73e2
MD5 3f8664f19080142a481b87632f1f649f
BLAKE2b-256 e1cfa0cde6b0e79d4e359c5dd3f7f2b6d3b0455376034f9e444ab5fa2adaeaf3

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