Cyberpunk 2077" is a very popular single-player game ~

The game is set in the year 2077, a highly developed technology but chaotic and disorderly "cyberpunk" city.

In this world, although the technology is highly developed, but the standard of living of human beings is extremely low, or the standard of living of the poor is extremely low.

Moreover, in addition to a very small number of rich capitalists, the rest are all poor.

So, this is a world of extremes, containing a very large number of elements. Visually, the bustling three-dimensional city is full of neon lights, artificial light is all the light source, and there is not even sunlight.

Correspondingly, in the slums, it is dark and humid.

Virtual and real boundaries are blurred, artificial intelligence and artificial people are silly, the poor and the rich are extremely divided, and terrorism abounds everywhere.

This issue is about introducing a "cyberpunk" style Python package, "mplcyberpunk".


Mplcyberpunk GitHub


First install via pip.

pip install mplcyberpunk


Let's look at the first example first.

import matplotlib.pyplot as plt
import mplcyberpunk

# Add style"cyberpunk")

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

# Set line glow + area map


Obtain a line glow area map.


It does fit well with the neon style of cyberpunk, artificial light.


A look at the library's source code file reveals two main functions of the library.


That is, make_lines_glow (line glow) and add_underglow (line area map).


We will use each method once in the following.

import numpy as np
import mplcyberpunk
import matplotlib.pyplot as plt"cyberpunk")

# Data
x = np.arange(-7, 7, 0.1)
y1 = np.sin(x)
y2 = np.sin(x) + x
y3 = np.sin(x) * x
y4 = np.sin(x) / x
plt.plot(x, y1)
plt.plot(x, y2)
plt.plot(x, y3)
plt.plot(x, y4)

# Line glow
# Area Map

# Save image


The first one is the default format, the second one adds line glow, and the third one is line glow + area map.



There are also some other types of colors that can be customized.

The default colormap is cool.

import matplotlib.pyplot as plt
from matplotlib import cm
import mplcyberpunk
import numpy as np

# time
t = np.arange(0, 6.4, 0.1)
# frequency
f = 1
amplitudes = np.arange(-10, 11, 1)
# amplitude
A = [x * np.cos(f*t) for x in amplitudes]

# Set color style,cool、spring、winter、tab20、coolwarm
colormap_sect = np.linspace(0, 1, len(amplitudes))
colors = [cm.coolwarm(x) for x in colormap_sect]

plt.rcParams['figure.figsize'] = [6, 4]"cyberpunk")

for i in range(21):
    plt.plot(t, A[i], color=colors[i])

# Title Name,cool、spring、winter、tab20、coolwarm
plt.title("Colormap: 'coolwarm'")


Get a chart of 5 color schemes.



Finally, a "cyberpunk" style map can be generated.

The ridge map used is the ridge_map.


ridge_map GitHub  

# Installation
pip install ridge_map
# Installing library dependencies
pip install scikit-image==0.14.2


Note here that you need to specify version 0.14.2 when installing scikit-image, otherwise it will report an error.

Since the library ridge_map has more content, I won't expand on it.

import matplotlib.font_manager as fm
import matplotlib.pyplot as plt
from ridge_map import RidgeMap
import mplcyberpunk

# Cyberpunk style"cyberpunk")

# Chinese display
plt.rcParams['font.sans-serif'] = ['SimHei'] # Windows
plt.rcParams['font.sans-serif'] = ['Hiragino Sans GB'] # Mac
plt.rcParams['axes.unicode_minus'] = False

# Fonts
font_prop = fm.FontProperties(fname="name.ttf")

# Get the data, special skills are needed here to succeed
rm = RidgeMap(bbox=(-156.250305, 18.890695, 154.714966, 20.275080), font=font_prop)

# Set the number of lines, orientation, and other properties
values = rm.get_elevation_data(num_lines=200, viewpoint='north')
values = rm.preprocess(values=values,

# Set title, line color, background color, etc.
rm.plot_map(values, label="夏威夷", kind='gradient', line_color=plt.get_cmap('spring'), background_color='#212946')


Get the ridge map of Hawaii Island, punk style full of it!




It seems to be possible to use the heightmaps format images directly, interested partners, you can try it yourself!




Related articles

Heartrate: Real-time Visualization for Python Execution

Heartate - Track programs like a heart rate,Heartrate is a Python tool library that allows you to visualize the execution of Python programs in real time. Monitoring a running Python program is shown in the following figure.

Implementing reverse proxies with Django only

When you think of reverse proxies, you say nginx. nginx is the ideal reverse proxy tool. But now the conditions are tough. The server doesn't have nginx and doesn't have root privileges, which means you can't compile and install nginx, and only one port,

What does join mean in python?

Python has two functions .join() and os.path.join(), which do the following: . join(): Concatenate string arrays. Concatenates the elements of a string, a tuple, and a list with the specified characters (separator) to generate a new string os.path.join()

Add new content to the python dict

Adding new content to a dictionary is done by adding new key/value pairs, modifying or deleting existing key/value pairs as in the following examples

How to delete elements in python dict

clear() method is used to clear all the data in the dictionary, because it is an in-place operation, so it returns None (also can be interpreted as no return value)

python crawler how to get cookies

Cookie, refers to the data (usually encrypted) that some websites store on the user's local terminal in order to identify the user and perform session tracking. For example, some websites require login to access a page, before login, you want to grab the

How OpenCV tracks objects in video

Each frame of the video is a picture, tracking an object in the video, decomposition down, in fact, is to find that object in each frame of the picture.