← 返回章节索引

CHAPTER 04 · 作品已接入

主题风格

用 style 切换明暗主题,快速统一整体气质。

Theme Styleslight themedark theme
import matplotlib.pyplot as plt

with plt.style.context('seaborn-v0_8-white'):
plt.plot(x, y)
plt.show()

with plt.style.context('dark_background'):
plt.plot(x, y)
plt.show()
颜色线型数据标记字体主题风格