Skip to main content

Monochromatic colorscheme for matplotlib with opinionated sensible default

Project description

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

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

monoplt-0.1.1.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file monoplt-0.1.1.tar.gz.

File metadata

  • Download URL: monoplt-0.1.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for monoplt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 57f377161ec30863011bf2181ab28dc1762f6ae089eabb02be6733e9506053ba
MD5 d48dd6da4faef19df3b2ba199ef84b4a
BLAKE2b-256 0beef2384e9fd5882c45ed777382e12f301587ef4917b1fe53a8d927be9006a1

See more details on using hashes here.

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