1

QtConsole3使用以下命令运行:

ipython3 qtconsole --cache-size=4000 --matplotlib=inline --colors=Linux

并用以下几行绘制一个图形:

In [1]: import numpy as np

In [2]: import matplotlib.pyplot as plt

In [3]: x = np.linspace(-1, 1, 1024) * 4 * np.pi

In [4]: y = np.sin(x) / x

In [5]: plt.plot(x, y)

但是图中的轴和标签都消失了,因为内联图是透明的,背景是黑色的。 在此处输入图像描述

那么如何QtConsole使用一些额外的参数运行以使内联图形正确显示?

4

1 回答 1

1

您可以在绘图之前以编程方式更改 rcparams

matplotlib.rcParams['figure.facecolor'] = "(1, 1, 1)"

或在您的 matplotlibrc 文件中;或者你可以是明确的:

fig = figure(facecolor='w')
ax = fig.add_subplot(111)
ax.plot(x, y)
fig
于 2015-06-21T21:32:58.043 回答