Skip to main content

MatPlotTheme is a theming library for MatPlotLib.

Project description

https://pypip.in/version/MatPlotTheme/badge.svg https://pypip.in/py_versions/MatPlotTheme/badge.svg https://pypip.in/license/MatPlotTheme/badge.svg https://travis-ci.org/James-Yu/MatPlotTheme.svg?branch=master

MatPlotTheme is a theming library for MatPlotLib. Greatly inspired by 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

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

Documentation

Read documentation.

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).

# 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.

# 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. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MatPlotTheme-0.1.2.zip (1.5 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page