Skip to content
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

Rasterized points not rendering when markeredgecolor is none #3711

Closed
jesaerys opened this issue Oct 23, 2014 · 10 comments
Closed

Rasterized points not rendering when markeredgecolor is none #3711

jesaerys opened this issue Oct 23, 2014 · 10 comments
Milestone

Comments

@jesaerys
Copy link

Points can be rasterized by setting their zorder attribute to a value less than the rasterization_zorder value of the current axes. However, I cannot get this to work if I set markeredgecolor to 'none'. Here is an example:

import matplotlib.pyplot as plt
ax = plt.subplot(1, 1, 1)
ax.set_rasterization_zorder(0)

# red point, no border
ax.plot(0, 0, linestyle='none', marker='o', markersize=100,
        markerfacecolor='r', markeredgecolor='none', zorder=1)

# rasterized green point, black border
ax.plot(1, 0, linestyle='none', marker='o', markersize=100,
        markerfacecolor='g', markeredgecolor='k', zorder=-1)

# rasterized blue point, no border
ax.plot(2, 0, linestyle='none', marker='o', markersize=100,
        markerfacecolor='b', markeredgecolor='none', zorder=-1)

ax.axis([-0.5, 2.5, -1, 1])
plt.savefig('test.pdf')

Everything works as expected in an interactive window, but the blue point is invisible in the pdf. The only difference between the red point and the blue point is zorder, and the only difference between the green point and the blue point is markeredgecolor. The invisibility of the blue point in the pdf therefore seems to be caused by a combination of rasterization and not having an edge.

I discovered this while running some old plotting scripts I wrote when I was using matplotlib 1.3 installed via pip for homebrew python on Mac OS 10.6.8. I'm now using anaconda python for Mac OS 10.9, which comes with matplotlib 1.4.1. I feel like there must be some connection with either the updated matplotlib or the anaconda python distribution (after all, my old scripts used to produce the correct output), but I cannot test this without reverting my entire python installation.

Does anyone know what could be going on here?

@jesaerys
Copy link
Author

FYI: I also tried setting markeredgecolor of the blue point to something other than 'none' and then setting markeredgewidth to zero. The blue point is invisible in the pdf in this case as well.

My current workaround for hiding the border of a rasterized point is to just set markeredgecolor to the same value as markerfacecolor, and then make markersize a bit smaller to compensate.

@tacaswell tacaswell added this to the v1.4.x milestone Oct 23, 2014
@tacaswell
Copy link
Member

cc @jkseppan

@jkseppan
Copy link
Member

Even odder: if I save to a png file, it only has the green dot. Svg works the same as pdf.

If this code used to work right with matplotlib 1.3, we could try git bisect to find the cause of the problem.

@francois-a
Copy link

Similar observation when saving rasterized points to PNG with markeredgewidth=0. The points are visible in figure window, but absent in the PNG; the axes render fine. This issue is new to 1.4.1, I don't see it with 1.4.0

@jesaerys
Copy link
Author

Glad it's not just me experiencing this! @F0a, thanks for confirming the version dependence.

@mdboom
Copy link
Member

mdboom commented Oct 24, 2014

Does #3699 resolve the issue? It think this is a dupe of #3687/#3699.

@jesaerys
Copy link
Author

I'm trying to test my example in branch 1.4.x to see if the issue is fixed with #3699, but I'm having trouble installing it. In a new conda environment, I've done pip install git+https://github.com/matplotlib/matplotlib.git@v1.4.x. It apparently builds successfully, but attempting to import pyplot gives me,

RuntimeError: Python is not installed as a framework. The Mac OS X backend will
not be able to function correctly if Python is not installed as a framework.
See the Python documentation for more information on installing Python as a
framework on Mac OS X. Please either reinstall Python as a framework, or try
one of the other backends.

Maybe someone who already has a working installation of the 1.4.x branch can do a quick test of the example? In the meantime, I'll continue to work on getting branch 1.4.x.

@jesaerys
Copy link
Author

I've tested the original example with the 1.4.x branch (I got it working using the QT backend) and I get the same result: no blue point in the pdf. Also, only the green point is visible in the interactive QT window, so whatever is causing this also affects certain interactive backends.

@tacaswell
Copy link
Member

@jesaerys If the bug is in the Agg backend, then it will also affect all of the interactive backends that use Agg for rendering.

@tacaswell
Copy link
Member

This should be resolved by #3699 and/on #3687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants