-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Bug report
Bug summary
Markers in line plots and scatter plots cannot be created without antialiasing. The argument antialiased=False is ignored. The scatter dots are still antialiased when calling
plt.scatter(..., antialiased=False)
plt.plot(..., marker="o", antialiased=False)
The line of a line plot as well as a Circle are however obeying to turning the antialiasing off.
Code for reproduction
I will provide a not-so-minimal example here, but which allows to directly observe the difference between antialiased=True and antialiased=False within matplotlib and can potentially directly be used as a test for the issue.
The following produces a two-part image, each with a line, a circle (red, nose) and a scatter and a line plot with marker (orange, eyes). In the left part all artists are being given the antialiased=True, in the right part antialiased=False.
import io
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
fig, axes = plt.subplots(ncols=2, figsize=(.5,.25), dpi=72)
fig.subplots_adjust(0,0,1,1,0,0)
## Produce a line plot, a scatter and a circle
## Set antialiased=True, False to observe the difference.
for aa,ax in zip([True,False],axes):
ax.axis([0,3,0,3])
ax.axis("off")
ax.plot([.8,1.2,1.8,2.2],[1,.6,.6,1], antialiased=aa)
ax.scatter([2],[2],s=16,edgecolor="k",facecolor="C1", antialiased=aa)
ax.plot([1],[2],marker="o",ms=4,mec="k",mfc="C1", antialiased=aa)
c = plt.Circle((1.5,1.5), radius=0.35, edgecolor="k",
facecolor="C3", antialiased=aa)
ax.add_patch(c)
buf = io.BytesIO()
fig.savefig(buf)
#fig.savefig("test"+str(matplotlib.get_backend())+".png")
plt.close()
## Read and show the produced images from above as imshow
fig, (ax,ax2) = plt.subplots(ncols=2, figsize=(5,2.6))
buf.seek(0)
im = plt.imread(buf)
ax.imshow(im[:,:im.shape[1]//2], origin="upper")
ax2.imshow(im[:,im.shape[1]//2:], origin="upper")
ax.set_title("antialiased=True")
ax2.set_title("antialiased=False")
fig.suptitle(matplotlib.get_backend())
fig.savefig("antialiased"+str(matplotlib.get_backend())+".png")
plt.show()
Actual outcome
Expected outcome
In the right image, we would expect the orange dots to consist only of black and orange pixels, similar to the red circle (the nose).
Matplotlib version
- Operating system: Windows 8.1
- Matplotlib version: 2.2
- Matplotlib backend: TkAgg, same with Qt4Agg
- Python version: 2.7.10
