在黑色背景上的IPython qtconsole内联绘图无法正常工作

时间:2015-02-21 23:54:46

标签: python matplotlib ipython

我使用的是Enthought Canopy的Python 更新库后我遇到了一些问题。 第一个问题是,我不喜欢白色背景预设上的黑色前景,所以我通过添加

来改变这一点通过IPython配置

c.IPythonWidget.syntax_style ='monokai'

然而,这引发了一个新问题,因为现在不再正确显示完整的情节。我附上了两张图片,以便更清楚:

Plot is ok, but I dislike the color styles for the console The frame size for the plot is somehow overriden by the black color background of the console

之前看起来像这样: The setting for the true frame is around the title and axes numbering

我将非常感谢您的帮助,因为我不知道如何解决这个问题。 不知何故,边界不再被定义为围绕文本和轴的数字。

1 个答案:

答案 0 :(得分:1)

使用我的第二台显示器,我意识到滴答标签至少几乎看不到。因此,这与我为语法高亮和控制台外观所做的更改无关。 然后我不得不查看一般情况下如何创建情节 事实证明,我一直在寻找的东西叫做

' fig.patch.set_facecolor'

并且默认情况下,它的值设置为(1,1,1,0)而不是(1,1,1,1),因为它具有白色facecolor补丁。我没有在matplotlibrc配置文件中找到这样的值,所以我不得不在名为" figure.py"的文件中手动设置这个值。位于matplotlib文件夹中。
必须更改的行是行号327

    324 # the figurePatch name is deprecated
    325 self.patch = self.figurePatch = Rectangle(
    326     xy=(0, 0), width=1, height=1,
    327     facecolor='white', edgecolor=edgecolor,
    328     linewidth=linewidth)
    329 self._set_artist_props(self.patch)
    330 self.patch.set_aa(False)

从原始设置 facecolor = facecolor facecolor =' white'

我认为这不是一个好的解决方案,因为这会永久性地将facecolor设置为白色,除非您手动更改它。 此外,我发现了这个链接:

How to set opacity of background colour of graph wit Matplotlib

非常有助于说明补丁的用途。

Inline plotting on black background :)

相关问题