diff --git a/.gitignore b/.gitignore
index 2cd3510b..9a1e5311 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@ sdist/*
docs/api/*
docs/_rst/*
docs/_build/*
+docs/auto_examples/*
cover/*
MANIFEST
diff --git a/README.md b/README.md
index d005f8d6..1ebdb7be 100644
--- a/README.md
+++ b/README.md
@@ -4,51 +4,46 @@
[![Codecov](https://codecov.io/gh/SarthakJariwala/seaborn-image/branch/master/graph/badge.svg)](https://codecov.io/gh/SarthakJariwala/seaborn-image)
[![PyPI](https://img.shields.io/pypi/v/seaborn-image.svg)](https://pypi.org/project/seaborn-image/)
[![Documentation Status](https://readthedocs.org/projects/seaborn-image/badge/?version=latest)](https://seaborn-image.readthedocs.io/en/latest/?badge=latest)
+[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
+
-
-
-
-
+
Seaborn-like image data visualization using matplotlib, scikit-image and scipy.
## Description
-Seaborn-image is a seaborn like python **image** visualization and processing library
+Seaborn-image is a seaborn-like python **image** visualization and processing library
based on matplotlib, scipy and scikit-image.
-The aim of seaborn-image is to provide a high-level API to **process and plot attractive images quickly and effectively**.
+The aim of `seaborn-image` is to provide a high-level API to **process and plot attractive images quickly and effectively**.
## Documentation
-Check out the docs [here](https://seaborn-image.readthedocs.io/)
+Check out the docs [here](https://seaborn-image.readthedocs.io/).
## Installation
@@ -58,57 +53,5 @@ pip install seaborn-image
```
## Usage
-### Simple usage
-
-```python
-
-import seaborn_image as isns
-
-"""Plot image"""
-isns.imgplot(data)
-
-"""Plot image with scalebar"""
-isns.imgplot(data, dx=0.01, units="um")
-
-"""Add colorbar label"""
-isns.imgplot(data, dx=0.01, units="um", cbar_label="Height (nm)")
-```
-
-
-
-
-### Plot image with a histogram
-
-```python
-import seaborn_image as isns
-
-isns.imghist(data, dx=150, units="nm", cbar_label="Height (nm)", cmap="ice")
-```
-
-
-
-
-
-### Set context like seaborn
-
-```python
-
-import seaborn_image as isns
-
-isns.set_context("notebook") # Other options include paper, talk, presentation, poster
-```
-
-### Apply image filters (from scipy and skimage) and plot
-
-```python
-
-import seaborn_image as isns
-
-isns.filterplot(data, filter="gaussian", sigma=5, cbar_label="Height (nm)")
-```
-
-
-
-
-Check out the more information [here](https://seaborn-image.readthedocs.io/)
+Check out the [quickstart guide](https://seaborn-image.readthedocs.io/en/latest/quickstart.html) and [examples](https://seaborn-image.readthedocs.io/auto_examples/index.html).
diff --git a/docs/Makefile b/docs/Makefile
index 36a06da7..621c3510 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -51,7 +51,8 @@ help:
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
- rm -rf $(BUILDDIR)/* $(AUTODOCDIR)
+ rm -rf $(BUILDDIR)/*
+ rm -rf auto_examples/
$(AUTODOCDIR): $(MODULEDIR)
mkdir -p $@
diff --git a/docs/conf.py b/docs/conf.py
index 7345d211..f21c506a 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -8,17 +8,29 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
- "sphinxcontrib.images",
+ "sphinx_gallery.gen_gallery",
"matplotlib.sphinxext.plot_directive",
]
html_static_path = ["_static"]
-
+# for matplotlib plot-directive
plot_include_source = True
plot_formats = [("png", 90)]
plot_html_show_formats = False
plot_html_show_source_link = False
+# sphinx-gallery
+sphinx_gallery_conf = {
+ "examples_dirs": "../examples", # path to your example scripts
+ "gallery_dirs": "auto_examples", # path to where to save gallery generated output
+ "image_scrapers": ("matplotlib"), # collect images created
+ "capture_repr": (),
+ "download_all_examples": False,
+ "line_numbers": False,
+ "show_memory": False,
+ "thumbnail_size": (500, 500),
+}
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
@@ -76,7 +88,7 @@
"navbar_links": [
("Quickstart", "quickstart"),
("How-to?", "how_to"),
- ("Gallery", "gallery"),
+ ("Gallery", "auto_examples/index"),
("Releases", "https://github.com/SarthakJariwala/seaborn-image/releases", True),
("Reference", "reference"),
],
diff --git a/docs/gallery.rst b/docs/gallery.rst
deleted file mode 100644
index 719b2ecd..00000000
--- a/docs/gallery.rst
+++ /dev/null
@@ -1,26 +0,0 @@
-Gallery
-=======
-
-.. thumbnail:: ../examples/image_5.png
- :width: 300px
- :height: 200px
-
-
-.. thumbnail:: ../examples/image_1.png
- :width: 240px
- :height: 200px
-
-
-.. thumbnail:: ../examples/image_0.png
- :width: 240px
- :height: 200px
-
-
-.. thumbnail:: ../examples/image_3.png
- :width: 450px
- :height: 200px
-
-
-.. thumbnail:: ../examples/image_4.png
- :width: 200px
- :height: 200px
diff --git a/docs/index.rst b/docs/index.rst
index 26eb6d41..6410e792 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -2,19 +2,27 @@
seaborn-image: image data visualization
=======================================
-.. list-table::
+|img1| |img2| |img3| |img4|
- * - .. image:: ../examples/image_1.png
- :width: 150px
- :height: 140px
+.. |img1| image:: /auto_examples/images/thumb/sphx_glr_plot_image_hist_thumb.png
+ :width: 190px
+ :height: 180px
- .. image:: ../examples/image_5.png
- :width: 200px
- :height: 140px
+.. |img2| image:: /auto_examples/images/thumb/sphx_glr_plot_filter_thumb.png
+ :width: 140px
+ :height: 140px
- .. image:: ../examples/image_4.png
- :width: 140px
- :height: 140px
+.. |img3| image:: /auto_examples/images/thumb/sphx_glr_plot_fft_thumb.png
+ :width: 120px
+ :height: 120px
+
+.. |img4| image:: /auto_examples/images/thumb/sphx_glr_plot_filtergrid_thumb.png
+ :width: 140px
+ :height: 140px
+
+.. .. |img5| image:: /auto_examples/images/thumb/sphx_glr_plot_image_robust_thumb.png
+.. :width: 200px
+.. :height: 200px
Description
@@ -27,7 +35,7 @@ The aim of seaborn-image is to provide a high-level API to **process and plot at
**and effectively**.
To get started with ``seaborn_image``, check out the :doc:`quickstart page `.
-To view example images, check out the :doc:`gallery page `.
+To view example images, check out the :doc:`gallery page `.
For specific how-to questions, refer to the :doc:`how-to page `.
Check out the source code on `github `_.
@@ -84,7 +92,7 @@ Contents
Quickstart
How-to?
- Gallery
+ Gallery
License
Authors
Changelog
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 114b849f..ab0fd7d8 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,3 +1,3 @@
-sphinx==2.3.1
+sphinx==3.2.1
+sphinx-gallery==0.8.0
sphinx_bootstrap_theme==0.7.1
-sphinxcontrib-images==0.9.2
diff --git a/examples/README.rst b/examples/README.rst
new file mode 100644
index 00000000..23aa4ea7
--- /dev/null
+++ b/examples/README.rst
@@ -0,0 +1,4 @@
+Example gallery
+===============
+
+Seaborn-image example gallery
diff --git a/examples/image_0.png b/examples/image_0.png
deleted file mode 100644
index c977708b..00000000
Binary files a/examples/image_0.png and /dev/null differ
diff --git a/examples/image_1.png b/examples/image_1.png
deleted file mode 100644
index 225ecd87..00000000
Binary files a/examples/image_1.png and /dev/null differ
diff --git a/examples/image_2.png b/examples/image_2.png
deleted file mode 100644
index 51c7694b..00000000
Binary files a/examples/image_2.png and /dev/null differ
diff --git a/examples/image_3.png b/examples/image_3.png
deleted file mode 100644
index a13df3a2..00000000
Binary files a/examples/image_3.png and /dev/null differ
diff --git a/examples/image_4.png b/examples/image_4.png
deleted file mode 100644
index b8730d70..00000000
Binary files a/examples/image_4.png and /dev/null differ
diff --git a/examples/image_5.png b/examples/image_5.png
deleted file mode 100644
index a7c6b1a9..00000000
Binary files a/examples/image_5.png and /dev/null differ
diff --git a/examples/image_plot.py b/examples/image_plot.py
deleted file mode 100644
index 845844df..00000000
--- a/examples/image_plot.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import numpy as np
-
-import seaborn_image as isns
-
-# Load data
-data = np.loadtxt("../data/PolymerImage.txt", skiprows=1) * 1e9
-
-# Plot
-isns.imgplot(data, dx=4 / 256, units='um', cbar_label="Height (nm)")
diff --git a/examples/plot_fft.py b/examples/plot_fft.py
new file mode 100644
index 00000000..b359c7b2
--- /dev/null
+++ b/examples/plot_fft.py
@@ -0,0 +1,10 @@
+"""
+Fast Fourier Transform
+======================
+"""
+
+import seaborn_image as isns
+
+img = isns.load_image("polymer")
+
+_ = isns.fftplot(img, cmap="viridis", cbar=False, despine=False)
diff --git a/examples/plot_filter.py b/examples/plot_filter.py
new file mode 100644
index 00000000..2707ccf8
--- /dev/null
+++ b/examples/plot_filter.py
@@ -0,0 +1,10 @@
+"""
+Image Filter
+============
+"""
+
+import seaborn_image as isns
+
+img = isns.load_image("polymer")
+
+_ = isns.filterplot(img, "median", size=5, cmap="ice", despine=False)
diff --git a/examples/plot_filtergrid.py b/examples/plot_filtergrid.py
new file mode 100644
index 00000000..f9146301
--- /dev/null
+++ b/examples/plot_filtergrid.py
@@ -0,0 +1,19 @@
+"""
+FilterGrid
+==========
+"""
+
+import seaborn_image as isns
+
+img = isns.load_image("polymer")
+
+g = isns.FilterGrid(
+ img,
+ "gaussian",
+ row="sigma",
+ col="mode",
+ sigma=[2, 3, 4],
+ mode=["reflect", "nearest", "mirror"],
+ despine=False,
+ cmap="magma",
+)
diff --git a/examples/plot_image.py b/examples/plot_image.py
new file mode 100644
index 00000000..d035aa65
--- /dev/null
+++ b/examples/plot_image.py
@@ -0,0 +1,12 @@
+"""
+Image plot
+==========
+
+"""
+
+import seaborn_image as isns
+
+img = isns.load_image("polymer")
+img_scale = {"dx": 15, "units": "nm"}
+
+_ = isns.imgplot(img, dx=15, units="nm", despine=False)
diff --git a/examples/plot_image_hist.py b/examples/plot_image_hist.py
new file mode 100644
index 00000000..d0750536
--- /dev/null
+++ b/examples/plot_image_hist.py
@@ -0,0 +1,10 @@
+"""
+Image distribution
+==================
+
+"""
+import seaborn_image as isns
+
+img = isns.load_image("polymer")
+
+_ = isns.imghist(img, cmap="YlGnBu_r", dx=15, units="nm", despine=False)
diff --git a/examples/plot_image_robust.py b/examples/plot_image_robust.py
new file mode 100644
index 00000000..4a169479
--- /dev/null
+++ b/examples/plot_image_robust.py
@@ -0,0 +1,17 @@
+"""
+Outlier correction
+==================
+"""
+
+import matplotlib.pyplot as plt
+
+import seaborn_image as isns
+
+img = isns.load_image("polymer outliers")
+
+f, axes = plt.subplots(1, 2)
+
+_ = isns.imgplot(img, ax=axes[0], cmap="inferno", despine=False)
+_ = isns.imgplot(
+ img, ax=axes[1], robust=True, perc=(2, 99.99), cmap="inferno", despine=False
+)
diff --git a/images/sphx_glr_plot_fft_001.png b/images/sphx_glr_plot_fft_001.png
new file mode 100644
index 00000000..26a160f9
Binary files /dev/null and b/images/sphx_glr_plot_fft_001.png differ
diff --git a/images/sphx_glr_plot_filter_001.png b/images/sphx_glr_plot_filter_001.png
new file mode 100644
index 00000000..24b169b2
Binary files /dev/null and b/images/sphx_glr_plot_filter_001.png differ
diff --git a/images/sphx_glr_plot_filtergrid_001.png b/images/sphx_glr_plot_filtergrid_001.png
new file mode 100644
index 00000000..048bbc87
Binary files /dev/null and b/images/sphx_glr_plot_filtergrid_001.png differ
diff --git a/images/sphx_glr_plot_image_001.png b/images/sphx_glr_plot_image_001.png
new file mode 100644
index 00000000..caa42b5c
Binary files /dev/null and b/images/sphx_glr_plot_image_001.png differ
diff --git a/images/sphx_glr_plot_image_hist_001.png b/images/sphx_glr_plot_image_hist_001.png
new file mode 100644
index 00000000..5a8ed504
Binary files /dev/null and b/images/sphx_glr_plot_image_hist_001.png differ
diff --git a/images/sphx_glr_plot_image_robust_001.png b/images/sphx_glr_plot_image_robust_001.png
new file mode 100644
index 00000000..41f740bf
Binary files /dev/null and b/images/sphx_glr_plot_image_robust_001.png differ
diff --git a/noxfile.py b/noxfile.py
index fee79a20..ec9b3ce6 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -4,7 +4,7 @@
import nox
-locations = "src", "tests", "noxfile.py", "docs/conf.py"
+locations = "src", "tests", "noxfile.py", "docs/conf.py", "examples"
nox.options.sessions = "safety", "tests", "xdoctest"
diff --git a/poetry.lock b/poetry.lock
index a9790fd9..f270e95b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -128,7 +128,7 @@ requests = ">=2.7.9"
[[package]]
category = "dev"
description = "Cross-platform colored terminal text."
-marker = "sys_platform == \"win32\" or platform_system == \"Windows\" or python_version >= \"3.0\" and sys_platform == \"win32\""
+marker = "sys_platform == \"win32\" or platform_system == \"Windows\""
name = "colorama"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
@@ -808,6 +808,17 @@ version = "0.7.1"
[package.dependencies]
setuptools = "*"
+[[package]]
+category = "dev"
+description = "A Sphinx extension that builds an HTML version of any Python script and puts it into an examples gallery."
+name = "sphinx-gallery"
+optional = false
+python-versions = ">=3.5"
+version = "0.8.0"
+
+[package.dependencies]
+sphinx = ">=1.8.3"
+
[[package]]
category = "dev"
description = "sphinxcontrib-applehelp is a sphinx extension which outputs Apple help books"
@@ -844,21 +855,6 @@ version = "1.0.3"
lint = ["flake8", "mypy", "docutils-stubs"]
test = ["pytest", "html5lib"]
-[[package]]
-category = "dev"
-description = "Sphinx extension for thumbnails"
-name = "sphinxcontrib-images"
-optional = false
-python-versions = "*"
-version = "0.9.2"
-
-[package.dependencies]
-requests = ">2.2,<3"
-
-[package.dependencies.sphinx]
-python = ">=3.0"
-version = ">=2.0"
-
[[package]]
category = "dev"
description = "A sphinx extension which renders display math in HTML via JavaScript"
@@ -990,7 +986,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["jaraco.itertools", "func-timeout"]
[metadata]
-content-hash = "280366d108fcf4931daac4a77aeac213a9a3f3868c788abf61a7e125dea3b8f4"
+content-hash = "835e1088c93eeda8e1e8c613b092d99e1531d193491f2d7b5f4a7a7091e655ec"
python-versions = "^3.6"
[metadata.files]
@@ -1493,6 +1489,9 @@ sphinx = [
sphinx-bootstrap-theme = [
{file = "sphinx-bootstrap-theme-0.7.1.tar.gz", hash = "sha256:571e43ccb76d4c6c06576aa24a826b6ebc7adac45a5b54985200128806279d08"},
]
+sphinx-gallery = [
+ {file = "sphinx-gallery-0.8.0.tar.gz", hash = "sha256:4b33e785a377d79779c355d0159ce0134442eb45d4d8fc1f5d081d237889e5b9"},
+]
sphinxcontrib-applehelp = [
{file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"},
{file = "sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a"},
@@ -1505,10 +1504,6 @@ sphinxcontrib-htmlhelp = [
{file = "sphinxcontrib-htmlhelp-1.0.3.tar.gz", hash = "sha256:e8f5bb7e31b2dbb25b9cc435c8ab7a79787ebf7f906155729338f3156d93659b"},
{file = "sphinxcontrib_htmlhelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:3c0bc24a2c41e340ac37c85ced6dafc879ab485c095b1d65d2461ac2f7cca86f"},
]
-sphinxcontrib-images = [
- {file = "sphinxcontrib-images-0.9.2.tar.gz", hash = "sha256:f0d5d720b69789c83bf1e6925093b32ab4cd6f925d24ecded56109fc0d0eb174"},
- {file = "sphinxcontrib_images-0.9.2-py2.py3-none-any.whl", hash = "sha256:db8d1b9cec0b71ba59ce1919d199a7d121bb7b916e96fb883c4f97b3f6bc6241"},
-]
sphinxcontrib-jsmath = [
{file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"},
{file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"},
diff --git a/pyproject.toml b/pyproject.toml
index f4b71f79..eb89e04c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,8 +33,8 @@ flake8-docstrings = "^1.5.0"
sphinx = "^3.2.1"
codecov = "^2.1.8"
sphinx_bootstrap_theme = "^0.7.1"
-sphinxcontrib-images = "^0.9.2"
xdoctest = "^0.14.0"
+sphinx-gallery = "^0.8.0"
[build-system]
requires = ["poetry>=0.12"]
diff --git a/src/seaborn_image/_filters.py b/src/seaborn_image/_filters.py
index 69d3b7c2..17bdecfb 100644
--- a/src/seaborn_image/_filters.py
+++ b/src/seaborn_image/_filters.py
@@ -236,6 +236,7 @@ def fftplot(
cbar_label=None,
cbar_ticks=None,
showticks=False,
+ despine=False,
):
if cmap is None:
@@ -257,6 +258,7 @@ def fftplot(
cbar_ticks=cbar_ticks,
showticks=showticks,
describe=False,
+ despine=despine,
)
return ax, cax
diff --git a/src/seaborn_image/_general.py b/src/seaborn_image/_general.py
index 7c7dadea..650053c1 100644
--- a/src/seaborn_image/_general.py
+++ b/src/seaborn_image/_general.py
@@ -476,8 +476,8 @@ def imghist(
ax2.get_xaxis().set_visible(False)
ax2.get_yaxis().set_visible(False)
- if despine:
- ax2.set_frame_on(False)
+ # if despine:
+ ax2.set_frame_on(False)
if cmap is None:
cm = get_cmap()