spiderplot
Python package to create 2D spider charts.
The spider chart is a type of relational graph y=f(x). The implementation is based on seaborn's lineplot() using a polar coordinate system.
Installation
The package can be installed via pip:
pip install spiderplot
Use the following commands for a quick verification of the installation.
python -c "import spiderplot; print(spiderplot.__version__)"
python -c "import spiderplot; spiderplot.demo_pair()"
Usage
Similar to seaborn functions, spiderplot accepts different data formats:
- array mode:
spiderplot(x=x, y=y)
withx,y(and other parameters) being sequences - long-form mode:
spiderplot(x=x, y=y, ..., data=data)
withdatabeing a DataFrame and the other parameters (x, y, hue, size, extent) being keys ofdata - wide-form mode:
spiderplot(data)
withdatabeing a DataFrame, using the following mapping:
xare the row indices (data.index)
yare the table values (data.values) every column ofdatarepresents a different category of the plot.
See this tutorial about data structures in seaborn for further details.
To print the help text of the function:
import spiderplot as sp
help(sp.spiderplot)
help(sp.spiderplot_facet)
See the examples for further usage information.
Basic example
import seaborn as sns
import spiderplot as sp
import matplotlib.pyplot as plt
sns.set_style("whitegrid")
# Load some demo data.
df = sp.demo.generate_data(mode="long-form", d=1)
# Create spider plot.
ax = sp.spiderplot(x="x", y="value", hue="dataset", legend=False,
data=df, palette="husl", rref=0)
# Adjust limits in radial direction.
ax.set_rlim([-1.4,1.4])
plt.show()
Multiple plots
df = sp.demo.generate_data_pair(mode="long-form")
sns.set_style("whitegrid")
ax = sp.spiderplot(x="x", y="value", hue="dataset", style="dataset",
data=df, dashes=False, palette="husl", rref=0)
ax.set_rlim([-1.4,1.4])
ax.legend(loc="upper right",
bbox_to_anchor=(1.4, 1.),
borderaxespad=0.)
plt.tight_layout()
plt.show()
Data aggregation
df = sp.demo.generate_data(mode="long-form", n=24, d=10)
means = df.groupby("x")["value"].mean()
stds = df.groupby("x")["value"].std()
sns.set_style("whitegrid")
ax = sp.spiderplot(y=means, extent=stds, color="red", fillcolor="gray",
fill=False, rref=0, label="mean ± std")
ax.set_rlim([-1.4,1.4])
ax.legend(loc="upper right",
bbox_to_anchor=(1.4, 1.),
borderaxespad=0.)
plt.tight_layout()
plt.show()
Requirements
Python>=3.6
numpy
pandas>=0.22
matplotlib>=3.0
seaborn>=0.9
Project setup
git clone https://github.com/hirsch-lab/spider-chart.git
cd spider-chart
pip install -r requirements.txt
# Run examples
./examples/run_all.py
# Build package
python setup.py sdist bdist_wheel
Metadata
Release files for spiderplot 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spiderplot-0.1.2.tar.gz | 24.3 MB | Without provenance | Details for spiderplot-0.1.2.tar.gz |
Release files / spiderplot-0.1.2.tar.gz
| Download URL | spiderplot-0.1.2.tar.gz |
|---|---|
| Size | 24.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
772cc3920ac23e23e7caf1f9fa35fa64fe08d9879757950e80a69bc686521852
|
|
BLAKE2b-256 checksum How to use checksums |
a5cd5e91772fa0f3ad30808c0e2ed0af862821157963c20463c129a7ea81159f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for spiderplot 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.