我想使用
matplotlib
两条曲线和一些置信区间在 Python 中进行绘图。我这样做:
import matplotlib.pyplot as plt
import numpy as np
# Generate fake data.
rng = np.random.default_rng(0)
y1 = np.cumsum(rng.uniform(0, 1, 10))
y2 = np.cumsum(rng.uniform(0, 1.5, 10))
# Plot the fake data and the fake confidence intervals.
fig, ax = plt.subplots()
ax.plot(y1)
ax.fill_between(range(len(y1)), y1 - 1, y1 + 1, alpha=0.2)
ax.plot(y2)
ax.fill_between(range(len(y2)), y2 - 1, y2 + 1, alpha=0.2)
plt.show()
结果如下:
。
这是一个玩具示例,我知道这些置信区间在数学上没有任何意义。
我的问题:我需要将图形保存为EPS(我不能使用其他格式),但是
fill_between
使用alpha=0.2
,并且EPS格式不支持透明度。有什么方法可以在不使用透明度的情况下生成相同的图吗?