黑色的背景样式表

此示例演示了 “dark_background” 样式,该样式使用白色表示通常为黑色的元素(文本,边框等)。请注意,并非所有绘图元素都默认为由rc参数定义的颜色。

黑色的背景样式表示例

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. plt.style.use('dark_background')
  4. fig, ax = plt.subplots()
  5. L = 6
  6. x = np.linspace(0, L)
  7. ncolors = len(plt.rcParams['axes.prop_cycle'])
  8. shift = np.linspace(0, L, ncolors, endpoint=False)
  9. for s in shift:
  10. ax.plot(x, np.sin(x + s), 'o-')
  11. ax.set_xlabel('x-axis')
  12. ax.set_ylabel('y-axis')
  13. ax.set_title("'dark_background' style sheet")
  14. plt.show()

下载这个示例