簡體   English   中英

Jupyter Notebook 中的暗模式繪圖 - Python

[英]Dark mode plots in Jupyter Notebook - Python

我正在使用 Jupyter Notebook,我目前正在使用來自 JupyterThemes 的深色日曬主題。

我注意到我的情節不是在黑暗模式下,文本仍然是黑色的,在日曬背景下不可讀。 JupyterThemes 的自述文件建議在 ~/.ipython/profile_default/startup/startup.ipy 中創建一個 startup.ipy 並編寫

# import jtplot submodule from jupyterthemes
from jupyterthemes import jtplot

# currently installed theme will be used to
# set plot style if no arguments provided
jtplot.style()

我已經創建了這個文件,但沒有任何改變。 我也嘗試過遵循本指南( https://medium.com/@rbmsingh/making-jupyter-dark-mode-great-5adaedd814db ),但我的情節再次沒有改變。

有什么幫助嗎? 我喜歡在 Jupyter Notebook 中使用暗模式,我希望有清晰的情節。

當我在暗模式下工作時,我在 matplotlib 導入之后添加了下面的樣式行,並且筆記本中的所有圖形都以黑色背景和白色文本格式化。

import matplotlib.pyplot as plt  
plt.style.use('dark_background')

希望這可以幫助

我遇到了同樣的問題,我解決了在( https://medium.com/@rbmsingh/making-jupyter-dark-mode-great-5adaedd814db )中將字符(')更改為('),現在它正在工作,如下文字已更正,祝你好運!

import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from jupyterthemes import jtplot

jtplot.style(theme='monokai', context='notebook', ticks=True, grid=False)

如果您的 Jupyter Notebook 是使用 Anaconda 安裝的。 您需要在 conda 環境中安裝 Jupyterthemes:

conda install -c conda-forge jupyterthemes

我找到了一種擴展 plot canvas 的解決方案,這樣 x 和 y 刻度就會變得可見。

在筆記本中導入 matplot lib 模塊后,您需要添加一行plt.style.use('default')

看到我的刻度之前在 canvas 之外。

添加該行后,刻度線已添加到 canvas 本身,無需進一步修改。

正如您在上圖中所見,這將拉動 canvas 中的 x 和 y 刻度,使其可見,而無需更改或修改刻度或 plot 顏色,這將使您與他人協作更容易。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM