注意
跳转至末尾 下载完整示例代码。
暗背景样式表#
本示例演示了“dark_background”样式,该样式对通常为黑色的元素(文本、边框等)使用白色。请注意,并非所有绘图元素都默认使用由 rc 参数定义的颜色。

import matplotlib.pyplot as plt
import numpy as np
plt.style.use('dark_background')
fig, ax = plt.subplots()
L = 6
x = np.linspace(0, L)
ncolors = len(plt.rcParams['axes.prop_cycle'])
shift = np.linspace(0, L, ncolors, endpoint=False)
for s in shift:
ax.plot(x, np.sin(x + s), 'o-')
ax.set_xlabel('x-axis')
ax.set_ylabel('y-axis')
ax.set_title("'dark_background' style sheet")
plt.show()