【发布时间】:2018-09-21 21:38:59
【问题描述】:
从 Jupyter 笔记本中保存 Matplotlib 图形时,如何覆盖默认的透明边框使其不透明?
查看savefig documentation,有几个参数似乎会影响这一点,但实际上似乎没有任何作用。这是一个例子。
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
x = np.linspace(-6, 6, 100)
ax.plot(x, np.sinc(x))
plt.savefig(
'test.png',
transparent=False, # no change
frameon=True, # no change
edgecolor='blue', # no change (want 'white' but 'blue' should be noticeable)
facecolor='red', # no change (want 'white' but 'red' should be noticeable)
alpha=1, # no change
)
这是结果。 StackOverflow 没有说明透明度,但是注意边缘不是'blue',面不是'red'。
【问题讨论】:
标签: python matplotlib plot jupyter-notebook transparency