New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fill_between in matplotlib does not handle “rasterized=True” option correctly #4837
Comments
eps/ps do not support alpha at all. What you are seeing is happening is that the alpha channel is getting dropped so you are seeing just the blue line, with no alpha. You can get something that looks correct here by doing import matplotlib as mp
import matplotlib.pyplot as plt
ALPHA=0.2
RASTERIZED=True
x = [0, 1, 2, 3]
y1 = [0, 0.1, 0.2, 0.3]
y2 = [0.01, 0.11, 0.21, 0.32]
fig, ax = plt.subplots(figsize=(4,4))
# note the zorder changes
ax.fill_between(x, y1, y2, alpha=ALPHA, color='red', lw=0, zorder=-5)
ax.fill_between(x, list(reversed(y1)), list(reversed(y2)), alpha=ALPHA, color='blue', lw=0, zorder=-4)
ax.set_rasterization_zorder(-1) # this is the important line
fig.savefig('plot.pdf')
fig.savefig('plot.eps')
fig.savefig('plot.ps')
fig.savefig('plot.png') which will cause all of the artists with a zorder less than -1 to be composited by agg which does know how to deal with alpha. |
Doesn't work for me, I'm afraid. Matplotlib version 1.4.2-3.1 |
Can you post the code and incorrect png output? |
Also, try updating to 1.4.3. |
The code: import matplotlib as mp
import matplotlib.pyplot as plt
ALPHA=0.2
RASTERIZED=True
x = [0, 1, 2, 3]
y1 = [0, 0.1, 0.2, 0.3]
y2 = [0.01, 0.11, 0.21, 0.32]
fig, ax = plt.subplots(figsize=(4,4))
ax.fill_between(x, y1, y2, alpha=ALPHA, color='red', lw=0, zorder=-5)
ax.fill_between(x, list(reversed(y1)), list(reversed(y2)), alpha=ALPHA, color='blue', lw=0, zorder=-4)
ax.set_rasterization_zorder(-1)
#ax.set_title('Plot')
#ax.set_ylabel('Units')
fig.savefig('plot.pdf')
fig.savefig('plot.png') PDF output looks the same. The Linux distribution I use does not have 1.4.3, but I'll try to upgrade it manually. |
This is fixed in 1.4.3. I just ran your code in a conda environment with both 1.4.2 and 1.4.3: 1.4.31.4.2You can also test at https://try.jupyter.org/ Closing as already fixed. |
OK, thanks. |
Thank you for the bug report, sorry we can't do any more for you. What linux distro do you use? I can make sure they are on the list of people I notify about future releases. |
kubuntu 15.04 |
The following script
Generates plots with empty fills, instead of rasterized transparencies.
The text was updated successfully, but these errors were encountered: