Metadata-Version: 2.1
Name: img2cmap
Version: 0.1.0
Summary: Create colormaps from images
Home-page: https://github.com/arvkevi/img2cmap
Author: Kevin Arvai
Author-email: arvkevi@gmail.com
License: MIT
Project-URL: Documentation, https://img2cmap.readthedocs.io/
Project-URL: Changelog, https://img2cmap.readthedocs.io/en/latest/changelog.html
Project-URL: Issue Tracker, https://github.com/arvkevi/img2cmap/issues
Keywords: matplotlib,colormap,image
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Utilities
Requires-Python: >=3.6
Provides-Extra: dev
License-File: LICENSE
License-File: AUTHORS.rst

========
img2cmap
========

**Create colormaps from images in three lines of code!**

| First, ``ImageConverter`` class converts images to arrays of RGB values.
| Then, ``generate_cmap`` creates a matplotlib `ListedColormap <https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.ListedColormap.html#matplotlib-colors-listedcolormap>`_.

.. code-block:: python3

    from img2cmap import ImageConverter

    converter = ImageConverter("tests/images/south_beach_sunset.jpg")
    cmap = converter.generate_cmap(n_colors=5, palette_name="south_beach_sunset", random_state=42)


Plot an image and a colorbar side by side.

.. code-block:: python3

    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import make_axes_locatable

    fig, ax = plt.subplots(figsize=(7, 5))

    ax.axis("off")
    img = plt.imread("tests/images/south_beach_sunset.jpg")
    im = ax.imshow(img, cmap=cmap)

    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="10%", pad=0.05)

    cb = fig.colorbar(im, cax=cax, orientation="vertical", label=cmap.name)
    cb.set_ticks([])

.. image:: images/colorbar.png
    :align: center

Now, use the colormap in your plots!

.. code-block:: python3

    import matplotlib.pyplot as plt

    colors = colormap.colors

    with plt.style.context("dark_background"):
        for i, color in enumerate(colors):
            plt.plot(range(10), [_+i+1 for _ in range(10)], color=color, linewidth=4)

.. image:: images/img2cmap_demo.png
    :align: center


Installation
============

::

    pip install img2cmap

You can also install the in-development version with::

    pip install https://github.com/arvkevi/img2cmap/archive/main.zip


Documentation
=============


https://img2cmap.readthedocs.io/


Status
======





Development
===========

To run all the tests run::

    tox

Note, to combine the coverage data from all the tox environments run:

.. list-table::
    :widths: 10 90
    :stub-columns: 1

    - - Windows
      - ::

            set PYTEST_ADDOPTS=--cov-append
            tox

    - - Other
      - ::

            PYTEST_ADDOPTS=--cov-append tox


Changelog
=========

0.0.0 (2022-04-30)
------------------

* First release on PyPI.


