Skip to content

Commit

Permalink
Make readme language more compact and immediately clear
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Sep 28, 2023
1 parent 87f36eb commit 83a67e9
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,50 @@

# MatSpy

Sparse matrix spy plot and sparkline renderer. Supports:
Sparse matrix spy plot and sparkline renderer.

```python
from matspy import spy

spy(A)
```

<img src="doc/images/spy.png" width="400" alt="Spy Plot"/>

Supports:
* **SciPy** - sparse matrices and arrays like `csr_matrix` and `coo_array` [(demo)](demo.ipynb)
* **NumPy** - `ndarray` [(demo)](demo-numpy.ipynb)
* **[Python-graphblas](https://github.com/python-graphblas/python-graphblas)** - `gb.Matrix` [(demo)](demo-python-graphblas.ipynb)
* **[PyData/Sparse](https://sparse.pydata.org/)** - `COO`, `DOK`, `GCXS` [(demo)](demo-pydata-sparse.ipynb)

Features:
* Simple `spy()` method, similar to MatLAB's spy.
* Sparklines: `to_sparkline()` creates self-contained small spy plots for inline visuals.
* FAST.
* Simple `spy()` method plots non-zero structure of a matrix, similar to MatLAB's spy.
* Sparklines: `to_sparkline()` creates small self-contained spy plots for inline HTML visuals.
* FAST and handles very large matrices.

See a [Jupyter notebook demo](demo.ipynb).

## Quick Start

```shell
pip install matspy
```
or
```shell
conda install matspy
conda install matspy
```

```python
from matspy import spy

spy(A)
```

<img src="doc/images/spy.png" width="400" alt="Spy Plot"/>

## Methods
* `spy(A)`: Plot the sparsity pattern (location of nonzero values) of sparse matrix `A`.
* `to_sparkline(A)`: Return a small spy plot as a self-contained HTML string. Multiple sparklines can be automatically to-scale with each other using the `retscale` and `scale` arguments.
* `spy_to_mpl(A)`: Same as `spy()` but returns the matplotlib Figure without showing it.
* `to_spy_heatmap(A)`: Return the raw 2D array for spy plots.

#### Example: spy plot screenshot as a PNG image
## Examples

See the [demo notebook](demo.ipynb) for more.

#### Save spy plot as a PNG image

```python
fig, ax = matspy.spy_to_mpl(A)

fig.savefig("spy.png", bbox_inches='tight')
```

Expand Down Expand Up @@ -87,7 +89,7 @@ Large matrices are downscaled using two native matrix multiplies. The final dens

<img src="doc/images/triple_product.png" height="125" width="400" alt="triple product"/>

Note: the spy plots in this image were created with `to_sparkline()`.
Note: the spy plots in this image were created with `to_sparkline()`. Code in the [demo notebook](demo.ipynb).

# Spy Plot Anti-Aliasing
One application of spy plots is to quickly see if a matrix has a noticeable structure.
Expand All @@ -114,4 +116,4 @@ Each package that MatSpy supports implements two classes:

See [matspy/adapters](matspy/adapters) for details.

You may use `matspy.register_driver` to register a Driver for your own matrix class.
You may use `matspy.register_driver` to register a `Driver` for your own matrix class.

0 comments on commit 83a67e9

Please sign in to comment.