Python 在Jupyter中,默认情况下如何使用matplotlib ggplot样式?

Python 在Jupyter中,默认情况下如何使用matplotlib ggplot样式?,python,matplotlib,jupyter,Python,Matplotlib,Jupyter,在jupyter笔记本中,我可以跑步 plt.style.use('ggplot') 这允许我使用ggplot样式进行绘图。我如何将其设置为默认值,比如说,将其放在某个配置文件中 一种方法是使用IPython的启动文件为所有IPython会话运行任意脚本。 要使其正常工作,您需要将任何文件.py放入/.ipython/profile\u default/startup文件夹。 然后,此文件可以包含以下代码,这些代码将在IPython启动时执行: import matplotlib.pyplot

在jupyter笔记本中,我可以跑步

plt.style.use('ggplot')

这允许我使用ggplot样式进行绘图。我如何将其设置为默认值,比如说,将其放在某个配置文件中

一种方法是使用IPython的启动文件为所有IPython会话运行任意脚本。 要使其正常工作,您需要将任何
文件.py
放入
/.ipython/profile\u default/startup
文件夹。 然后,此文件可以包含以下代码,这些代码将在IPython启动时执行:

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

另一种方法是使用
ggplot
的设置修改
matplotlibrc
,您可以通过以下方式获得:

plt.style.library['ggplot']
这将输出:

RcParams({u'axes.axisbelow': True,
          u'axes.edgecolor': u'white',
          u'axes.facecolor': u'#E5E5E5',
          u'axes.grid': True,
          u'axes.labelcolor': u'#555555',
          u'axes.labelsize': u'large',
          u'axes.linewidth': 1.0,
          u'axes.prop_cycle': cycler(u'color', [u'#E24A33', u'#348ABD', u'#988ED5', u'#777777', u'#FBC15E', u'#8EBA42', u'#FFB5B8']),
          u'axes.titlesize': u'x-large',
          u'figure.edgecolor': u'0.50',
          u'figure.facecolor': u'white',
          u'font.size': 10.0,
          u'grid.color': u'white',
          u'grid.linestyle': u'-',
          u'patch.antialiased': True,
          u'patch.edgecolor': u'#EEEEEE',
          u'patch.facecolor': u'#348ABD',
          u'patch.linewidth': 0.5,
          u'xtick.color': u'#555555',
          u'xtick.direction': u'out',
          u'ytick.color': u'#555555',
          u'ytick.direction': u'out'})    

将这些行(
key:value
part)粘贴到
matplotlibrc
的末尾将使
ggplot
样式默认有效。

一种方法是使用IPython的启动文件为所有IPython会话运行任意脚本。 要使其正常工作,您需要将任何
文件.py
放入
/.ipython/profile\u default/startup
文件夹。 然后,此文件可以包含以下代码,这些代码将在IPython启动时执行:

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

另一种方法是使用
ggplot
的设置修改
matplotlibrc
,您可以通过以下方式获得:

plt.style.library['ggplot']
这将输出:

RcParams({u'axes.axisbelow': True,
          u'axes.edgecolor': u'white',
          u'axes.facecolor': u'#E5E5E5',
          u'axes.grid': True,
          u'axes.labelcolor': u'#555555',
          u'axes.labelsize': u'large',
          u'axes.linewidth': 1.0,
          u'axes.prop_cycle': cycler(u'color', [u'#E24A33', u'#348ABD', u'#988ED5', u'#777777', u'#FBC15E', u'#8EBA42', u'#FFB5B8']),
          u'axes.titlesize': u'x-large',
          u'figure.edgecolor': u'0.50',
          u'figure.facecolor': u'white',
          u'font.size': 10.0,
          u'grid.color': u'white',
          u'grid.linestyle': u'-',
          u'patch.antialiased': True,
          u'patch.edgecolor': u'#EEEEEE',
          u'patch.facecolor': u'#348ABD',
          u'patch.linewidth': 0.5,
          u'xtick.color': u'#555555',
          u'xtick.direction': u'out',
          u'ytick.color': u'#555555',
          u'ytick.direction': u'out'})    
将这些行(
key:value
part)粘贴到
matplotlibrc
的末尾,默认情况下会使
ggplot
样式生效