MatPlotTheme
============

.. image:: https://pypip.in/version/MatPlotTheme/badge.svg
   :target: https://pypi.python.org/pypi/MatPlotTheme
.. image:: https://pypip.in/py_versions/MatPlotTheme/badge.svg
   :target: https://pypi.python.org/pypi/MatPlotTheme
.. image:: https://pypip.in/license/MatPlotTheme/badge.svg
   :target: http://opensource.org/licenses/MIT
.. image:: https://travis-ci.org/James-Yu/MatPlotTheme.svg?branch=master
   :target: https://travis-ci.org/James-Yu/MatPlotTheme

MatPlotTheme is a theming library for `MatPlotLib <http://matplotlib.org/>`_. Greatly inspired by `prettyplotlib <https://github.com/olgabot/prettyplotlib/>`_, MatPlotTheme aims to provide easy-to-use APIs for creating proper and attractive data visualizations.

In MatPlotTheme, theming MatPlotLib figures is controlled by ``style`` and ``palette``, which defines how elements are customized and which colors are used, respectively. As MatPlotTheme provides multiple styles/palettes (at least that is what I am working on), using the library is as simple as picking a style-palette combination and plot. What's more, MatPlotTheme inherits MatPlotLib's API configuration, which means existing code can be migrated with minimal effort.

Examples
--------

.. image:: https://raw.githubusercontent.com/James-Yu/MatPlotTheme/master/matplottheme/tests/baseline_images/summary/default.png
   :width: 100%

Documentation
-------------
Read `documentation <http://matplottheme.readthedocs.org/>`_.

Usage
-----

MatPlotTheme provides a default ``Style`` and a default ``Palette``. Each of them are python classes and all other styles/palettes are derived classes of them. ``matplottheme`` provides interfaces to all plotting methods in ``Style``, which enable library usage like ``matplottheme.plot(ax, x, y)``.

.. code-block:: python

   # Use API provided by matplottheme module
   import matplottheme as mpt
   import matplotlib.pylab as plt
   import numpy as np
   
   x = np.arange(1000)
   y = np.random.normal(size=1000).cumsum()

   fig = plt.figure()
   ax = fig.add_subplot(111)
   # MatPlotTheme plots a line using ggplot2 style/palette
   mpt.set_theme('ggplot2', 'ggplot2')
   mpt.plot(ax, x, y)
   
This code block can also generate the same plot as the first one.

.. code-block:: python

   # Use style/palette objects
   from matplottheme.style.ggplot2 import ggplot2Style
   from matplottheme.palette.ggplot2 import ggplot2Palette
   import matplotlib.pylab as plt
   import numpy as np
   
   x = np.arange(1000)
   y = np.random.normal(size=1000).cumsum()

   fig = plt.figure()
   ax = fig.add_subplot(111)
   # Manually using ggplot2 style/palette
   ggplot2Style(ggplot2Palette()).plot(ax, x, y)

Dependency
----------

- `MatPlotLib <http://matplotlib.org/>`_. ``pip install matplotlib`` is the most simple installation method.

License
-------
The MIT License (MIT)

Copyright (c) 2014 James Yu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.