Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有设置默认matplotlib样式的方便方法?_Matplotlib - Fatal编程技术网

有没有设置默认matplotlib样式的方便方法?

有没有设置默认matplotlib样式的方便方法?,matplotlib,Matplotlib,我在工作中经常使用matplotlib——了解我正在查看的数据,对我的网站进行可视化,并在论文中添加图表。这是一个很棒的工具。但我发现,默认打印样式虽然功能强大,但通过调整一些东西可以使其在视觉上更具吸引力 例如,每当我创建一个新轴时,我发现我更喜欢它具有特定的脊椎设置,以使其看起来更像簇绒: import matplotlib.pyplot as plt ax = plt.subplot(111) ax.xaxis.tick_bottom() ax.yaxis.tick_left() ax.

我在工作中经常使用
matplotlib
——了解我正在查看的数据,对我的网站进行可视化,并在论文中添加图表。这是一个很棒的工具。但我发现,默认打印样式虽然功能强大,但通过调整一些东西可以使其在视觉上更具吸引力

例如,每当我创建一个新轴时,我发现我更喜欢它具有特定的脊椎设置,以使其看起来更像簇绒:

import matplotlib.pyplot as plt

ax = plt.subplot(111)
ax.xaxis.tick_bottom()
ax.yaxis.tick_left()
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position(('outward', 6))
ax.spines['left'].set_position(('outward', 6))
每当我想要一个新的轴时,输入它是非常烦人的,所以我把它放在一个小模块中。我想知道的是,是否有办法以某种方式将这些“设置”保存在matplotlib中?我想没有,但我想我会看看有没有人有什么建议


我在上看到了一个类似的问题,但这个问题是针对matplotlibrc构造中的设置提出的。这个问题更多地针对(显然)必须以编程方式设置的设置。

只需将其设置为函数:

def gimmeanaxis():
  import matplotlib.pyplot as plt

  ax = plt.subplot(111)
  ax.xaxis.tick_bottom()
  ax.yaxis.tick_left()
  ax.spines['top'].set_color('none')
  ax.spines['right'].set_color('none')
  ax.spines['bottom'].set_position(('outward', 6))
  ax.spines['left'].set_position(('outward', 6))
  return ax

那你只需要打一次。添加您认为合适的选项(例如
、子批次名称等)

正在进行简化工作:啊,太棒了!很高兴看到这一切正在进行中。最新更新:我刚刚遇到了基本上是这样的,做得更好。我想我会在这里大喊一声。