深色背景樣式表#

此範例示範「dark_background」樣式,它將白色用於通常為黑色的元素(文字、邊框等)。 請注意,並非所有繪圖元素的預設顏色都由 rc 參數定義。

'dark_background' style sheet
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()

由 Sphinx-Gallery 產生的圖庫