Skip to main content

Add-on for Matplotlib to produce 'Cyberpunk' style plots

Project description

mplcyberpunk

Latest PyPI version example workflow Python 3.12

A Python package on top of matplotlib to create 'cyberpunk' style plots with 3 additional lines of code.

Installation

pip install mplcyberpunk

Usage

After importing the package, the cyberpunk stylesheet (dark background etc.) is available via plt.style.use. The line glow and 'underglow' effects are added via calling add_glow_effects:

import matplotlib.pyplot as plt
import mplcyberpunk

plt.style.use("cyberpunk")

plt.plot([1, 3, 9, 5, 2, 1, 1], marker='o')
plt.plot([4, 5, 5, 7, 9, 8, 6], marker='o')

mplcyberpunk.add_glow_effects()

plt.show()

Result:

This effect is currently only implemented for lines.

The individual steps are described here in more detail.

Add effects individually

Instead of add_glow_effects, you can add the line glow and underglow effects separately:

mplcyberpunk.make_lines_glow()
mplcyberpunk.add_underglow()

You can also add the effect to a specific axis object explicitly:

fig, ax = plt.subplots()
...
mplcyberpunk.make_lines_glow(ax)

To activate the glow effect only for specific lines, pass a Line2D object or a list of Line2Ds to make_lines_glow.

Gradient glow

Gradient underglow effect can be added with

mplcyberpunk.add_glow_effects(gradient_fill=True)

or independently of line glow with

mplcyberpunk.add_gradient_fill(alpha_gradientglow=0.5)

add_gradient_fill takes a gradient_start argument for different gradient starting values:

gradient_start

Different glow configurations:

underglows

Scatter plots

Glow effect can be added to scatter plots via mplcyberpunk.make_scatter_glow():

Colormap

The default colormap is cool:

colormap

Others:

colormaps

Bar charts

import matplotlib.pyplot as plt
import mplcyberpunk

plt.style.use('cyberpunk')

categories = ['A', 'B', 'C', 'D', 'E']
values = [25, 67, 19, 45, 10]
colors = ["C0", "C1", "C2", "C3", "C4"]

bars = plt.bar(categories, values, color=colors, zorder=2)

mplcyberpunk.add_bar_gradient(bars=bars)

plt.show()

colormap

Gallery

europe world

gradient-fill_1 gradient-fill_2

Some images can be bought as posters here.

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

mplcyberpunk-0.7.6.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

mplcyberpunk-0.7.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file mplcyberpunk-0.7.6.tar.gz.

File metadata

  • Download URL: mplcyberpunk-0.7.6.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mplcyberpunk-0.7.6.tar.gz
Algorithm Hash digest
SHA256 797cb36b5e1e178e7a3da5f4f215e469ef13935fd8c99d1cd20112e90bba7e22
MD5 262ab7e7331028f8d0c5379caf151ec1
BLAKE2b-256 21539cf3da89c28374b92a2cb9b975fd1031858e0eaee31edd762e3a4619ecb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mplcyberpunk-0.7.6.tar.gz:

Publisher: test-deploy.yml on dhaitz/mplcyberpunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mplcyberpunk-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: mplcyberpunk-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mplcyberpunk-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5884f7add690a418695ef2f598257fedef89758c17884448518a307470590b42
MD5 2af42717edfd31366375963060746d5c
BLAKE2b-256 138f14ede5882332b013db2479f32b0678ff4bf4f648c5e8bce20b9f97d646bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mplcyberpunk-0.7.6-py3-none-any.whl:

Publisher: test-deploy.yml on dhaitz/mplcyberpunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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