Monochromatic colorscheme for matplotlib with opinionated sensible default

Overview

Monochromatic colorscheme for matplotlib with opinionated sensible default

If you need a simple monochromatic colorscheme for your matplotlib figures, this is probably for you. No fancy colors and unnecessary distractions.

To install, simply run this on terminal:

pip install monoplt

or if you want the latest development version, run this instead:

pip install git+https://github.com/ariaghora/monoplt

Usage

from monoplt import apply_monochrome_style, generate_pattern_cycler
import matplotlib.pyplot as plt
apply_monochrome_style(plt)

Example: line plot

plt.figure(figsize=(7,5))
for i in range(1,5):
    plt.plot(np.arange(10), np.arange(10)*i, label=i)
plt.xlabel("$x$")
plt.ylabel("$f(x)$")
plt.legend(facecolor='white', framealpha=1)
plt.show()

line

Example: bar plot

For plots involving fill colors (e.g., bar plot, histogram, etc.), this will give you some trouble since all colors are black, and no distinction between plotted groups. To mitigate this issue, we can use generate_pattern_cycler() to get a cycler of fill patterns that characterize each group.

styles = generate_pattern_cycler()

plt.figure(figsize=(7, 5))
for x in range(1,5):
    plt.bar(x, np.random.randint(2,10), label=f"Bar {x}", **next(styles))
plt.xlabel("Category")
plt.ylabel("Amount")
plt.show()

line

Example: histogram

styles = generate_pattern_cycler()
plt.figure(figsize=(7, 5))
x = np.random.randn(1000)
plt.hist(x, bins=30, density=True, **next(styles))
plt.xlabel("$x$")
plt.ylabel("$f(x)$")
plt.show()

line

Example: pie

plt.figure(figsize=(7, 5))
pie = plt.pie(
    [2, 3, 1, 5, 7, 9], 
    labels=["two", "three", "one", "five", "seven", "nine"],
)

styles = generate_pattern_cycler()
for part in pie[0]:
    part.set(**next(styles))

line

Heavily adopted from Olsgaard's post

You might also like...
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

:small_red_triangle: Ternary plotting library for python with matplotlib
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Joyplots in Python with matplotlib & pandas :chart_with_upwards_trend:
Joyplots in Python with matplotlib & pandas :chart_with_upwards_trend:

JoyPy JoyPy is a one-function Python package based on matplotlib + pandas with a single purpose: drawing joyplots (a.k.a. ridgeline plots). The code f

A python package for animating plots build on matplotlib.
A python package for animating plots build on matplotlib.

animatplot A python package for making interactive as well as animated plots with matplotlib. Requires Python = 3.5 Matplotlib = 2.2 (because slider

Painlessly create beautiful matplotlib plots.
Painlessly create beautiful matplotlib plots.

Announcement Thank you to everyone who has used prettyplotlib and made it what it is today! Unfortunately, I no longer have the bandwidth to maintain

basemap - Plot on map projections (with coastlines and political boundaries) using matplotlib.

Basemap Plot on map projections (with coastlines and political boundaries) using matplotlib. ⚠️ Warning: this package is being deprecated in favour of

Easily convert matplotlib plots from Python into interactive Leaflet web maps.
Easily convert matplotlib plots from Python into interactive Leaflet web maps.

mplleaflet mplleaflet is a Python library that converts a matplotlib plot into a webpage containing a pannable, zoomable Leaflet map. It can also embe

Design your own matplotlib stylefile interactively

Tired of playing with font sizes and other matplotlib parameters every time you start a new project or write a new plotting function? Want all you plots have the same style? Use matplotlib configuration files!

A Python library for plotting hockey rinks with Matplotlib.
A Python library for plotting hockey rinks with Matplotlib.

Hockey Rink A Python library for plotting hockey rinks with Matplotlib. Installation pip install hockey_rink Current Rinks The following shows the cus

Owner
Aria Ghora Prabono
Researcher | Coder
Aria Ghora Prabono
Cartopy - a cartographic python library with matplotlib support

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation easy. Table of contents Overview Get in touch License an

null 1.2k Jan 1, 2023
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 10.2k Dec 30, 2022
The windML framework provides an easy-to-use access to wind data sources within the Python world, building upon numpy, scipy, sklearn, and matplotlib. Renewable Wind Energy, Forecasting, Prediction

windml Build status : The importance of wind in smart grids with a large number of renewable energy resources is increasing. With the growing infrastr

Computational Intelligence Group 125 Dec 24, 2022
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

Devin Pleuler 30 Feb 22, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 16.7k Jan 8, 2023
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 8.1k Feb 13, 2021
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Marc 611 Dec 29, 2022
Joyplots in Python with matplotlib & pandas :chart_with_upwards_trend:

JoyPy JoyPy is a one-function Python package based on matplotlib + pandas with a single purpose: drawing joyplots (a.k.a. ridgeline plots). The code f

Leonardo Taccari 462 Jan 2, 2023
A python package for animating plots build on matplotlib.

animatplot A python package for making interactive as well as animated plots with matplotlib. Requires Python >= 3.5 Matplotlib >= 2.2 (because slider

Tyler Makaro 394 Dec 18, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 13.1k Feb 18, 2021